Codes
Codes
ViewBag.Title = "Index";
Layout = "~/Views/Shared/_Layout.cshtml";
}
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
<script
src="https://cdn.jsdelivr.net/jquery.validation/1.16.0/jquery.validate.min.js"></
script>
@{
var View = (List<CustomerManagments.Models.Data>)ViewData["View"];
var GetState = (List<CustomerManagments.Models.Data>)ViewData["GetState"];
var GetDist = ViewData["GetDist"] as List<CustomerManagments.Models.Data>;
}
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
<script
src="https://cdn.jsdelivr.net/jquery.validation/1.16.0/jquery.validate.min.js"></
script>
<script type="text/javascript">
//$(document).ready(function () {
// // Function to show/hide the additional text boxes for Wholesaler option
// $("#txtCustomerType").change(function () {
// var customerType = $(this).val();
// var wholesalerFields = $("#wholesalerFields");
function AddData() {
// Perform validation
var name = $("#txtShopname").val();
var mobile = $("#txtMobile").val();
var customerType = $("#txtCustomerType").val();
var beatCode = $("#txtBeatCode").val();
var callFrequency = $("#txtCallFrequency").val();
var district = $("#txtDistrict").val();
var city = $("#txtCity").val();
var state = $("#txtState").val();
function GetAll(TempCustomerId) {
$.ajax({
url: "/CM/View",
type: "GET",
data: { TempCustomerId: TempCustomerId },
success: function (response) {
$("#TempCustomerId").val(response[0].TempCustomerId);
$("#txtShopname").val(response[0].ShopName);
$("#txtMobile").val(response[0].Mobile);
$("#txtCustomerType").val(response[0].CustomerType);
$("#txtBeatCode").val(response[0].BeatCode);
$("#txtCallFrequency").val(response[0].CallFrequency);
$("#txtDistrict").val(response[0].District);
$("#txtCity").val(response[0].City);
$("#txtState").val(response[0].State);
$
("#txtAverageBusinessLink").val(response[0].AverageBusinessLink);
$
("#txtWholesalerDistributors").val(response[0].WholesalerDistributors);
$
("#txtInteriorMarketName").val(response[0].txtInteriorMarketName);
$("#btnsave").hide();
$("#btnupdate").show();
$('html,body').animate({
scrollTop: $("#User").offset().top
}, 1000);
}
});
}
//function GetDistribtours(EmployeeID) {
// $.ajax({
// url: "/CM/GetDistribtours",
// type: "GET",
// data: { EmployeeID: EmployeeID },
// success: function (response) {
// $("#EmployeeID").val(response[0].EmployeeID);
// var customerType = $(this).val();
// var wholesalerFields = $("#wholesalerFields");
// var AverageBusinessLink = $("txtAverageBusinessLink");
// var InteriorMarketName = $("txtInteriorMarketName");
// var WholesalerDistributors = $("txtWholesalerDistributors");
// $('html,body').animate({
// scrollTop: $("#User").offset().top
// }, 1000);
// }
// });
//}
$(document).ready(function () {
$.ajax({
url: '@Url.Action("GetBeats", "CM")',
type: 'GET',
dataType: 'json',
data: { employeeID: 22 },
success: function (data) {
var dropdown = $('#txtBeatCode');
$.each(data, function (index, beat) {
dropdown.append($('<option></option>').val(beat.BeatName).text(beat.MergedValue));
});
}
});
});
$(document).ready(function () {
$.ajax({
url: '/CM/GetState', // Replace with the correct URL to fetch the
states
type: 'GET',
dataType: 'json',
success: function (data) {
var dropdown = $('#txtState');
$.each(data, function (index, state) {
dropdown.append($('<option></option>').val(state.StateName).text(state.StateName));
});
}
});
});
$(document).ready(function () {
$.ajax({
url: '/CM/GetDist',
type: 'GET',
dataType: 'json',
data: { employeeID: 22 },
success: function (data) {
var dropdown = $('#txtLinkDistributors');
$.each(data, function (index, beat) {
dropdown.append($('<option></option>').val(beat.CustomerType).text(beat.CustomerTyp
e));
});
}
});
});
function Getstatus(UserID) {
$.ajax({
url: "/CM/View",
type: "GET",
data: { UserID: UserID },
success: function (response) {
$("#TempCustomerId").val(response[0].TempCustomerId);
$("#txtShopname").val(response[0].ShopName);
$("#txtMobile").val(response[0].Mobile);
$("#txtCustomerType").val(response[0].CustomerType);
$("#txtBeatCode").val(response[0].BeatCode);
$("#txtCallFrequency").val(response[0].CallFrequency);
$("#txtDistrict").val(response[0].District);
$("#txtCity").val(response[0].City);
$("#txtState").val(response[0].State);
$("#txtAverageBusinessLink").val(response[0].AverageBusinessLink);
$
("#txtWholesalerDistributors").val(response[0].WholesalerDistributors);
$("#txtInteriorMarketName").val(response[0].txtInteriorMarketName);
$("#btnsave").hide();
$("#btnupdate").show();
$('html,body').animate({
scrollTop: $("#User").offset().top
}, 1000);
}
});
}
</script>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>@ViewBag.Title</title>
<style>
body {
font-family: Arial, sans-serif;
background-color: #f2f2f2;
}
h1 {
text-align: center;
margin-top: 16px;
color: #000000;
}
form {
max-width: 500px;
margin: 0 auto;
background-color: #fff;
padding: 20px;
border-radius: 5px;
box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
}
input[type="text"],
select {
width: 100%;
padding: 10px;
background-color: #f2f2f2;
margin-bottom: 10px;
border: 1px solid #ccc;
border-radius: 4px;
}
button {
padding: 10px 20px;
background-color: #4CAF50;
color: #fff;
border: none;
border-radius: 4px;
cursor: pointer;
}
table {
width: 100%;
border-collapse: collapse;
margin-top: 20px;
}
th,
td {
border: 1px solid #ccc;
padding: 8px;
}
th {
background-color: rgba(0, 0, 0, 0.1);
}
.viewbtn {
padding: 5px 10px;
background-color: #428bca;
color: #fff;
border: none;
border-radius: 4px;
cursor: pointer;
}
</style>
</head>
<body>
<div>
<div align="center">
<h1>CUSTOMER ADDITION</h1>
<form id="User">
<input type="text" id="EmployeeID" name="EmployeeID"
style="display:none" />
<input type="text" id="TempCustomerId" name="TempCustomerId"
style="display: none" />
ShopName:
<input type="text" id="txtShopname" name="txtShopname"
placeholder="Enter your Shopname" /><br><br>
<label for="txtShopname" class="col-sm-6" id="lblname"
name="lblname"></label><br /><br />
Mobile:
<input type="text" id="txtMobile" name="txtMobile"
placeholder="Enter your Mobile" /><br><br>
<label for="txtMobile" class="col-sm-6" id="lblMobile"
name="lblMobile"></label><br /><br />
CustomerType:
<select id="txtCustomerType" name="txtCustomerType">
<option value="" id="wholesalerFields">Select Customer
Type</option>
<option value="Wholesaler"
id="wholesalerFields">Wholesaler</option>
<option value="Retailer">Retailer</option>
</select><br>
<label for="txtCustomerType" class="col-sm-6"
id="lblCustomerType"></label><br /><br />
Link Distributors:
<option value="@item.CustomerType">@item.CustomerType</option>
</select>
<label for="txtLinkDistributors" class="col-sm-6"
id="lblWholesalerDistributors" name="lblWholesalerDistributors"></label><br
/><br />
BeatCode:
<select id="txtBeatCode" name="txtBeatCode">
<option value="">Select BeatCode</option>
</select>
<label for="txtBeatCode" class="col-sm-6"
id="lblBeatCode"></label><br /><br />
Call Frequency:
<input type="text" id="txtCallFrequency" name="txtCallFrequency"
placeholder="Enter your CallFrequency" /><br><br>
<label for="txtCallFrequency" class="col-sm-6"
id="lblCallFrequency"></label><br /><br />
District:
<input type="text" id="txtDistrict" name="txtDistrict"
placeholder="Enter your District" /><br><br>
<label for="txtDistrict" class="col-sm-6"
id="lblDistrict"></label><br /><br />
City:
<input type="text" id="txtCity" name="txtCity" placeholder="Enter
your City" /><br><br>
<label for="txtCity" class="col-sm-6" id="lblCity"></label><br
/><br />
State:
<select id="txtState" name="txtState" placeholder="Enter your
State">
<option value="">State</option>
@foreach (var item in GetState)
{
<option value="@item.StateName">@item.StateName</option>
}
</select>
<label for="txtState" class="col-sm-6" id="lblState"></label><br
/><br />
</form>
</div>
</div>
<table align="center" border="6">
<thead>
<tr>
<th>Date of Request</th>
<th>Customer Name</th>
<th>Mobile</th>
<th>Customer Type</th>
<th>BeatCode</th>
<th>Status</th>
<th>Action</th>
</tr>
</thead>
<tbody id="tbody">
@foreach (var item in View)
{
<tr>
<td>@item.CreatedOn</td>
<td>@item.ShopName</td>
<td>@item.Mobile</td>
<td>@item.CustomerType</td>
<td>@item.BeatCode</td>
<td>@item.Status</td>
@*<td>@item.StateName</td>*@
@*<td id="[email protected]">@item.Status<*@
@*<td>@item.CallFrequency</td>
<td>@item.District</td>
<td>@item.City</td>
<td>@item.State</td>*@
@*<td>@item.Status</td>*@
<td>
<button class="viewbtn"
onclick="GetAll('@item.TempCustomerId')">VIEW</button>
@*<button class="viewbtn"
onclick="GetAll('@item.TempCustomerId'); GetStatus('@item.UserID'); return
false;">VIEW</button>*@
</td>
</tr>
}
</tbody>
</table>
@*<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
<script
src="https://cdn.jsdelivr.net/jquery.validation/1.16.0/jquery.validate.min.js"></
script>
<script type="text/javascript">
function AddData() {
// Perform validation
var name = $("#txtShopname").val();
var mobile = $("#txtMobile").val();
var customerType = $("#txtCustomerType").val();
var beatCode = $("#txtBeatCode").val();
var callFrequency = $("#txtCallFrequency").val();
var district = $("#txtDistrict").val();
var city = $("#txtCity").val();
var state = $("#txtState").val();
function GetAll(TempCustomerId) {
$.ajax({
url: "/CM/View",
type: "GET",
data: { TempCustomerId: TempCustomerId },
success: function (response) {
$("#TempCustomerId").val(response[0].TempCustomerId);
$("#txtShopname").val(response[0].ShopName);
$("#txtMobile").val(response[0].Mobile);
$("#txtCustomerType").val(response[0].CustomerType);
$("#txtBeatCode").val(response[0].BeatCode);
$("#txtCallFrequency").val(response[0].CallFrequency);
$("#txtDistrict").val(response[0].District);
$("#txtCity").val(response[0].City);
$("#txtState").val(response[0].State);
$("#btnsave").hide();
$("#btnupdate").show();
$('html,body').animate({
scrollTop: $("#User").offset().top
}, 1000);
}
});
}
$(document).ready(function () {
$.ajax({
url: '@Url.Action("GetBeats", "CM")',
type: 'GET',
dataType: 'json',
data: { employeeID: 22 },
success: function (data) {
var dropdown = $('#txtBeatCode');
$.each(data, function (index, beat) {
dropdown.append($('<option></option>').val(beat.BeatName).text(beat.MergedValue));
});
}
});
});
function toggleWholesalerFields() {
var customerType =
document.getElementById("txtCustomerType").value;
var wholesalerFields = document.getElementById("wholesalerFields");
</script>*@
</body>
</html>