My Edit modal popup is not showing

  • 13 Views
  • Last Post 10 April 2023
[email protected] posted this 10 April 2023

[HttpGet]

        public ActionResult UpStaffDetail()

        {

            using (var db = new ASPNETMASTERPOSTEntities())

            {

                var dataList = db.tblCompanies.Include("tblStaffs").ToList();

                var modifiedData = dataList.AsEnumerable().SelectMany(x => x.tblStaffs.Select(d => new StaffManagementModel

                {

                    CompanyId = x.CompanyId,

                    DateJoin = x.DateJoin,

                    Department = x.Department,

                    JobTitle = x.JobTitle,

                    StaffId = d.StaffId,

                    Picture = d.Picture,

                    StaffNo = d.StaffNo,

                    FName = d.FName,

                    LName = d.LName,

                    BirthDate = d.BirthDate,

                    PhoneNo = d.PhoneNo,

                    Email = d.Email,

                    FirstName = d.FirstName,

                    LastName = d.LastName,

                    PhoneNumb = d.PhoneNumb

                })).FirstOrDefault();

 

                return Json(modifiedData, JsonRequestBehavior.AllowGet);

            }

        }

 

function upStaffDetails($StaffId)

        {

           

            var tblStaffs = [];

            var company = new Object();

            var staff = new Object();

            $("#staffId").val($StaffId);

            if ($StaffId != 0)

            {

                jQuery.ajax({

                    url: "@Url.Action("UpStaffDetail", "Home")" + "?StaffId=" + $StaffId + "&Department=abc",

                    data{

                        company: company

                    }),

                type: "Get",

                dataType: "json",

                contentType: "application/json; charset=utf-8",

                success: function (result) {

                    company: company

                    console.log(result);

                    if (result != null) {

                        $("#staffId").val(staff.StaffId);

                        $("#companyId").val(company.CompanyId);

                        $("#date").val(company.DateJoin);

                        $("#department").val(company.Department);

                        $("#jobTilte").val(company.JobTitle);

                        $("#image").val(staff.Picture);

                        $("#staffNo").val(staff.StaffNo);

                        $("#fName").val(staff.FName);

                        $("#lName").val(staff.LName);

                        $("#birthDate").val(staff.BirthDate);

                        $("#phone").val(staff.PhoneNo);

                        $("#email").val(staff.Email);

                        $("#firstName").val(staff.FirstName);

                        $("#lastName").val(staff.LastName);

                        $("#phonenumber").val(staff.PhoneNumb);

                        tblStaffs.push(staff);

                        company.tblStaffs = tblStaffs;

                    }

 

                }

            });

[email protected] posted this 10 April 2023

This is my Html Code

<div ng-controller="HomeStaffManagementList">

    <div class="modal fade" id="StaffModal">

        <div class="modal-dialog modal-lg " style=" width: 900px !important;">

            <div class="modal-content">

                <div class="modal-header pt-2 pb-2">

                    <h4>Add New / Update Staff</h4>

                    <a href="#" class="close" data-dismiss="modal">&times;</a>

 

                </div>

                <form id="NewOrderForm">

                    <div class="modal-body">

                        @*Customer Details*@

                        <h5 style="color:#ff6347">Staff Profile</h5>

                        <hr />

                        <div class="form-horizontal">

                            <input type="hidden" id="companyId" />

                            <input type="hidden" id="staffId" />

                            <!-- Gutter g-1 -->

                            <div class="row g-1">

                                <div class="col">

                                    @*<div class="form-horizontal">*@

                                    <!-- Name input -->

                                    <div class="form-outline">

 

                                        <label class="form-label" for="date"> Date Join</label>

                                        <input type="date" id="date" name="date" class="form-control-range">

 

                                        <label class="form-label" for="department">Department</label>

                                        <input type="text" id="department" name="name" placeholder="Enter Department" class="form-control" required />

 

                                    </div>

 

                                </div>

                                <div class="col">

                                    <!-- Email input -->

                                    <div class="form-outline">

                                        <label class="form-label" for="jobTilte">Job Title</label>

                                        <input type="text" id="jobTilte" name="jobTilte" placeholder="Enter Job Title" class="form-control" required />

                                        <img src="" style="margin:10px" height="80" width="100" id="imagepreview"/>

                                        <input type="file" name="ImageUpload" accept="image/jpg, image/png" onchange="ShowImagePreview(this, document.getElementById('imagepreview'))" />

                                               @*<img src="image" id="image" width="40">*@

                                               @*upload photo><input type="file" id="image" name="image">*@

                                    </div>

                                </div>

                            </div>

                            <hr />

                            @*Staff Details*@

                            <h5 style="margin-top:10px;color:#ff6347">Staff Details</h5>

                            <hr />

                            <div class="row g-1">

                                <div class="col">

 

                                    <!-- Name input -->

                                    <div class="form-outline">

                                        <label class="form-label" for="staffNo">Staff No</label>

                                        <input type="text" id="staffNo" name="staffNo" placeholder="Enter Staff number" class="form-control" required />

 

                                    </div>

                                </div>

                                <div class="col">

 

                                    <!-- Name input -->

                                    <div class="form-outline">

                                        <label class="form-label" for="fName">First Name</label>

                                        <input type="text" id="fName" name="fName" placeholder="First Name" class="form-control" required />

 

                                    </div>

                                </div>

                                <div class="col">

 

                                    <!-- Name input -->

                                    <div class="form-outline">

                                        <label class="form-label" for="lName">Last Name</label>

                                        <input type="text" id="lName" name="fName" placeholder="Last Name" class="form-control" required />

 

                                    </div>

                                </div>

                            </div>

                            <div class="row g-1">

                                <div class="col">

                                    <!-- Name input -->

                                    <div class="form-outline">

                                        <label class="form-label" for="birthDate">Birth Date</label>

                                        <input type="date" id="birthDate" name="birthDate" placeholder="Enter Birth Date" class="form-control-range" required />

 

                                    </div>

                                </div>

                                <div class="col">

                                    <!-- Email input -->

                                    <div class="form-outline">

                                        <label class="form-label" for="phone">Phone Number</label>

                                        <input type="number" id="phone" name="phone" placeholder="Enter Phone Number" class="form-control" required />

 

                                    </div>

                                </div>

                                <div class="col">

                                    <!-- Email input -->

                                    <div class="form-outline">

                                        <label class="form-label" for="email">Email</label>

                                        <input type="email" id="email" name="email" placeholder="Enter Email... example.com" class="form-control" required />

 

                                    </div>

                                </div>

 

                            </div>

                            <hr />

                            @*Next of King Details*@

                            <h5 style="margin-top:10px;color:#ff6347">Next of King Details</h5>

                            <hr />

                            <div class="row g-1">

                                <div class="col">

 

                                    <!-- Name input -->

                                    <div class="form-outline">

                                        <label class="form-label" for="firstName">First Name</label>

                                        <input type="text" id="firstName" name="firstName" placeholder="First Name" class="form-control" required />

 

                                    </div>

                                </div>

                                <div class="col">

                                    <!-- Name input -->

                                    <div class="form-outline">

                                        <label class="form-label" for="lastName">Last Name</label>

                                        <input type="text" id="lastName" name="lastName" placeholder="Last Name" class="form-control" required />

 

                                    </div>

                                </div>

                                <div class="col">

                                    <!-- Name input -->

                                    <div class="form-outline">

                                        <label class="form-label" for="phonenumber">Phone Number</label>

                                        <input type="number" id="phonenumber" name="phonenumber" placeholder="Phone Number" class="form-control" required />

 

                                    </div>

                                </div>

                            </div>

                        </div>

 

                        <div class="mb-12">

                            <div class="form-group">

                            </div>

                        </div>

                    </div>

 

                    <div class="modal-footer">

                        <button type="reset" class="btn btn-default" data-dismiss="modal">Close</button>

                        <button id="success-message" type="button" onclick="saveStaffProfile()" class="btn btn-danger">Save Order</button>

                        @*<a href="#" ng-click="saveToCart()" type="submit"  class="btn btn-primary "></a>*@

                    </div>

 

                </form>

            </div>

        </div>

    </div>

 

 

Close