コード例 #1
0
        public static string UpdateAdminList(List <AdminMasterModal> data)
        {
            using (var context = new SalesReturndbEntities())
            {
                using (TransactionScope transaction = new TransactionScope())
                {
                    foreach (var Obj in data)
                    {
                        //CommonDAL.CheckIfEmployeeExist(Obj.VPName);



                        var duplicateCheck = context.TblAdminMasters.Where(x => x.Admin_Id == Obj.Admin_Id && x.IsActive == true).FirstOrDefault();

                        if (duplicateCheck != null)
                        {
                            var duplicateCheckValue = context.TblAdminMasters.Where(x => x.EmployeeCode == Obj.EmployeeCode && x.Admin_Id != Obj.Admin_Id && x.IsActive == true).FirstOrDefault();
                            if (duplicateCheckValue == null)
                            {
                                duplicateCheck.EmployeeCode = Obj.EmployeeCode;

                                duplicateCheck.ModifiedBy   = Obj.CreatedBy;
                                duplicateCheck.ModifiedDate = DateTime.Now;



                                context.Entry(duplicateCheck).State = EntityState.Modified;
                                context.SaveChanges();
                            }
                        }
                        else
                        {
                            var duplicateCheckValue = context.TblAdminMasters.Where(x => x.EmployeeCode == Obj.EmployeeCode && x.IsActive == true).FirstOrDefault();
                            if (duplicateCheckValue == null)
                            {
                                TblAdminMaster marix = new TblAdminMaster()
                                {
                                    EmployeeCode = Obj.EmployeeCode,
                                    IsActive     = true,
                                    CreatedBy    = Obj.CreatedBy,
                                    CreatedDate  = DateTime.Now,
                                };

                                context.Entry(marix).State = EntityState.Added;
                                context.SaveChanges();
                            }
                        }
                    }

                    transaction.Complete();
                    transaction.Dispose();
                }

                return("Success : Admin list successfully updated.");
            }
        }
コード例 #2
0
        public static string CloseRequest(CloseRequestObjForStg_4 data)
        {
            using (var context = new SalesReturndbEntities())
            {
                string AssignTo       = string.Empty;
                string RetMsg         = string.Empty;
                var    RequestDetail  = context.tblRequestDtls.Where(x => x.RequestHeaderId == data.Request_Id).ToList();
                var    approvalHeader = context.TblApproverHeaders.Where(x => x.Request_Id == data.Request_Id).FirstOrDefault();
                var    ReqHdr         = context.TblRequestHeaders.Where(x => x.RequestHeaderId == data.Request_Id && x.IsActive == true).FirstOrDefault();
                var    UserDetail     = context.SP_LFGDetails(approvalHeader.CreatedBy).FirstOrDefault();
                var    DlrDtl         = context.sp_GetDealerDtlBy_DealerRepositoryId(data.Request.DealerId).FirstOrDefault();
                if (data.FutureStatus_Id == 10027 || data.CurrentStatus_Id == 10028 || data.CurrentStatus_Id == 10029)
                {
                    var EmpMaster = context.TblEmployeeMasters.Where(x => x.DepotName == DlrDtl.Depot && x.IsActive == true).FirstOrDefault();
                    AssignTo = data.FutureStatus_Id == 10027 ? EmpMaster.Depotcode : "";
                    if (data.Request.IsCommercialSettlement == true)
                    {
                        var EpCheck = context.sp_CheckEPNumber(data.Request.EPNo).FirstOrDefault();
                        if (EpCheck == null)
                        {
                            return("Error: EP Number does not exists");
                        }
                    }
                    ReqHdr.IsCommercialSettlement        = data.Request.IsCommercialSettlement;
                    ReqHdr.MaterialWillGoToDealer        = data.Request.IsCommercialSettlement == true ? false : true;
                    ReqHdr.ReasonForCommercialSettlement = data.Request.IsCommercialSettlement == true ? data.Request.ReasonForCommercialSettlement : "";
                    ReqHdr.DetailsForMaterialGoToDealer  = data.Request.IsCommercialSettlement == false ? data.Request.DetailsForMaterialGoToDealer : "";
                    ReqHdr.EPNo         = data.Request.IsCommercialSettlement == true ? data.Request.EPNo : "";
                    ReqHdr.ModifiedBy   = data.EmployeeCode;
                    ReqHdr.ModifiedDate = DateTime.Now;

                    context.Entry(ReqHdr).State = System.Data.Entity.EntityState.Modified;
                    context.SaveChanges();

                    RetMsg = data.FutureStatus_Id == 10027 ? "Request has been forwarded to Depot!" : "Request has been closed successfully!";
                }
                else if (data.CurrentStatus_Id == 10030)
                {
                    ReqHdr.DocketNumber         = data.Request.DocketNumber;
                    ReqHdr.DocketDate           = data.Request.DocketDate;
                    context.Entry(ReqHdr).State = System.Data.Entity.EntityState.Modified;
                    context.SaveChanges();

                    RetMsg = "Request has been closed successfully!";
                }
                else
                {
                    RetMsg = "Request has been closed successfully!";
                }

                ApproverDAL.UpdateRequestStatus(false, Convert.ToInt32(data.Request_Id), data.EmployeeCode, AssignTo, data.Active_Role, data.Requested_Role, data.CurrentStatus_Id, data.FutureStatus_Id, data.Remarks);

                return("Success : " + ReqHdr.RequestTypeOption + data.Request_Id + " " + RetMsg);
            }
        }
コード例 #3
0
        public static string SaveRequestType(List <RequestTypeModal> list)
        {
            using (var context = new SalesReturndbEntities())
            {
                using (TransactionScope transaction = new TransactionScope())
                {
                    foreach (var obj in list)
                    {
                        var duplicateCheck = context.TblRequestTypes.Where(x => x.IsActive == true && x.RequestType_Id == obj.RequestType_Id).FirstOrDefault();

                        if (duplicateCheck != null)
                        {
                            var duplicateValueCheck = context.TblRequestTypes.Where(x => x.RequestType.Equals(obj.RequestType) && x.IsActive == true && x.RequestType_Id != obj.RequestType_Id).FirstOrDefault();

                            if (duplicateValueCheck == null)
                            {
                                //update
                                duplicateCheck.RequestType  = obj.RequestType;
                                duplicateCheck.ModifiedBy   = obj.EmployeeCode;
                                duplicateCheck.ModifiedDate = DateTime.Now;


                                context.Entry(duplicateCheck).State = System.Data.Entity.EntityState.Modified;
                                context.SaveChanges();
                            }
                        }
                        else
                        {
                            var duplicateValueCheck = context.TblRequestTypes.Where(x => x.RequestType.Equals(obj.RequestType) && x.IsActive == true).FirstOrDefault();

                            if (duplicateValueCheck == null)
                            {
                                //new entry
                                TblRequestType RequestType = new TblRequestType()
                                {
                                    RequestType = obj.RequestType,
                                    IsActive    = true,
                                    CreatedBy   = obj.EmployeeCode,
                                    CreatedDate = DateTime.Now,
                                };
                                context.Entry(RequestType).State = System.Data.Entity.EntityState.Added;
                                context.SaveChanges();
                            }
                        }
                    }
                    transaction.Complete();
                    transaction.Dispose();
                }
                return("Success : Request types succssfully saved");
            }
        }
コード例 #4
0
        public static string DeleteList(int id, string employeeCode)
        {
            using (var context = new SalesReturndbEntities())
            {
                using (TransactionScope transaction = new TransactionScope())
                {
                    var Check = context.TblEmployeeMasters.Where(x => x.IsActive == true && x.Id == id).FirstOrDefault();
                    if (Check != null)
                    {
                        //update
                        Check.IsActive     = false;
                        Check.ModifiedBy   = employeeCode;
                        Check.ModifiedDate = DateTime.Now;


                        context.Entry(Check).State = System.Data.Entity.EntityState.Modified;
                        context.SaveChanges();

                        transaction.Complete();
                        transaction.Dispose();
                    }
                }
                return("Success : succssfully deleted.");
            }
        }
コード例 #5
0
        public static string UpdateFlowList(List <FlowMatrixModel> obj)
        {
            using (var context = new SalesReturndbEntities())
            {
                foreach (var ob in obj)
                {
                    try
                    {
                        var InsrtData = context.TblFlowMatrices.Where(x => x.IsActive == true && x.Id == ob.Id).FirstOrDefault();

                        InsrtData.Id               = ob.Id;
                        InsrtData.ISC              = ob.ISC;
                        InsrtData.LogisticsHead    = ob.LogisticsHead;
                        InsrtData.President        = ob.President;
                        InsrtData.RH               = ob.RH;
                        InsrtData.SegmentHead      = ob.SegmentHead;
                        InsrtData.VP               = ob.VP;
                        InsrtData.ComplaintHandler = ob.ComplaintHandler;
                        InsrtData.ComplaintManager = ob.ComplaintManager;
                        InsrtData.ModifiedBy       = ob.ModifiedBy;

                        context.Entry(InsrtData).State = EntityState.Modified;
                        context.SaveChanges();
                    }
                    catch (Exception e)
                    {
                        Console.WriteLine(e);
                    }
                }


                return("Success");
            }
        }
コード例 #6
0
        public static string UpdateEmployeeList(List <EmployeeMasterModel> list)
        {
            using (var context = new SalesReturndbEntities())
            {
                using (TransactionScope transaction = new TransactionScope())
                {
                    List <EmployeeMasterModel> lst = new List <EmployeeMasterModel>();

                    foreach (var obj in list)
                    {
                        var duplicateCheck = context.TblEmployeeMasters.Where(x => x.IsActive == true && x.Id == obj.Id).FirstOrDefault();
                        if (duplicateCheck != null)
                        {
                            var check = lst.Where(x => x.IsActive == true && x.DepotName == obj.DepotName).FirstOrDefault();

                            if (check == null)
                            {
                                //update
                                duplicateCheck.DepotName        = obj.DepotName;
                                duplicateCheck.CommercialCode   = obj.CommercialCode;
                                duplicateCheck.CommercialHead   = obj.CommercialHead;
                                duplicateCheck.ComplaintHandler = obj.ComplaintHandler;
                                duplicateCheck.ComplaintManager = obj.ComplaintManager;
                                duplicateCheck.CSO           = obj.CSO;
                                duplicateCheck.Depotcode     = obj.Depotcode;
                                duplicateCheck.ISC           = obj.ISC;
                                duplicateCheck.LogisticsHead = obj.LogisticsHead;
                                duplicateCheck.ModifiedBy    = obj.CreatedBy;
                                duplicateCheck.ModifiedDate  = DateTime.Now;


                                context.Entry(duplicateCheck).State = System.Data.Entity.EntityState.Modified;
                                context.SaveChanges();

                                lst.Add(obj);
                            }
                            else
                            {
                                return("Duplicate value not allowed");
                            }
                        }
                        else
                        {
                            var duplicateCheck1 = context.TblEmployeeMasters.Where(x => x.IsActive == true && x.DepotName == obj.DepotName).FirstOrDefault();
                            if (duplicateCheck1 == null)
                            {
                                //new entry
                                TblEmployeeMaster ReasonMaster = new TblEmployeeMaster()
                                {
                                    DepotName        = obj.DepotName,
                                    CommercialCode   = obj.CommercialCode,
                                    CommercialHead   = obj.CommercialHead,
                                    ComplaintHandler = obj.ComplaintHandler,
                                    ComplaintManager = obj.ComplaintManager,
                                    CSO           = obj.CSO,
                                    Depotcode     = obj.Depotcode,
                                    ISC           = obj.ISC,
                                    LogisticsHead = obj.LogisticsHead,
                                    IsActive      = true,
                                    CreatedBy     = obj.CreatedBy,
                                    CreatedDate   = DateTime.Now,
                                };
                                context.Entry(ReasonMaster).State = System.Data.Entity.EntityState.Added;
                                context.SaveChanges();

                                lst.Add(obj);
                            }
                            else
                            {
                                return("Duplicate value not allowed");
                            }
                        }
                    }
                    transaction.Complete();
                    transaction.Dispose();
                }
                return("Success : succssfully saved");
            }
        }
コード例 #7
0
        public static string UpdateApprovalMatrix(List <ApprovalMatrixModal> data)
        {
            using (var context = new SalesReturndbEntities())
            {
                using (TransactionScope transaction = new TransactionScope())
                {
                    foreach (var Obj in data)
                    {
                        //CommonDAL.CheckIfEmployeeExist(Obj.VPName);

                        var duplicateCheck = context.TblApprovalMatrices.Where(x => x.Matrix_Id == Obj.Matrix_Id && x.IsActive == true).FirstOrDefault();

                        if (duplicateCheck != null)
                        {
                            duplicateCheck.Country = Obj.Country;

                            duplicateCheck.BUType      = Obj.BUType;
                            duplicateCheck.Division    = Obj.Division;
                            duplicateCheck.RequestType = Obj.RequestType;

                            duplicateCheck.SRV_Value  = Obj.SRV_Value;
                            duplicateCheck.InvoiceAge = Obj.InvoiceAge;

                            duplicateCheck.ComplaintHandler = Obj.ComplaintHandler;
                            duplicateCheck.ComplaintManager = Obj.ComplaintManager;

                            duplicateCheck.LogisticsManager = Obj.LogisticsManager;
                            duplicateCheck.LogisticsHead    = Obj.LogisticsHead;

                            duplicateCheck.SegmentHeadHRV    = Obj.SegmentHeadHRV;
                            duplicateCheck.SegmentInvoiceAge = Obj.SegmentInvoiceAge;

                            //duplicateCheck.VP = Obj.VPName;
                            //duplicateCheck.President = Obj.President;

                            duplicateCheck.ModifiedBy   = Obj.CreatedBy;
                            duplicateCheck.ModifiedDate = DateTime.Now;



                            context.Entry(duplicateCheck).State = EntityState.Modified;
                            context.SaveChanges();
                        }
                        else
                        {
                            TblApprovalMatrix marix = new TblApprovalMatrix()
                            {
                                Country           = Obj.Country,
                                BUType            = Obj.BUType,
                                Division          = Obj.Division,
                                RequestType       = Obj.RequestType,
                                SRV_Value         = Obj.SRV_Value,
                                InvoiceAge        = Obj.InvoiceAge,
                                ComplaintHandler  = Obj.ComplaintHandler,
                                ComplaintManager  = Obj.ComplaintManager,
                                LogisticsManager  = Obj.LogisticsManager,
                                LogisticsHead     = Obj.LogisticsHead,
                                SegmentHeadHRV    = Obj.SegmentHeadHRV,
                                SegmentInvoiceAge = Obj.SegmentInvoiceAge,

                                //VP = Obj.VPName,
                                //President = Obj.President,

                                IsActive    = true,
                                CreatedBy   = Obj.CreatedBy,
                                CreatedDate = DateTime.Now,
                            };

                            context.Entry(marix).State = EntityState.Added;
                            context.SaveChanges();
                        }
                    }

                    transaction.Complete();
                    transaction.Dispose();
                }

                return("Success : Approval matrix successfully updated.");
            }
        }
コード例 #8
0
        public static string UpdateSAPSubReason(List <SAPReasonModel> list)
        {
            using (var context = new SalesReturndbEntities())
            {
                using (TransactionScope transaction = new TransactionScope())
                {
                    List <TblSAPReasonMaster> lst = new List <TblSAPReasonMaster>();

                    foreach (var obj in list)
                    {
                        var duplicateCheck = context.TblSAPReasonMasters.Where(x => x.IsActive == true && x.SAPReasonID == obj.SAPReasonID).FirstOrDefault();
                        if (duplicateCheck != null)
                        {
                            var check = lst.Where(x => x.IsActive == true && x.RequestTypeId == obj.RequestTypeId &&
                                                  x.SubReasonID == obj.SubReasonID).FirstOrDefault();

                            if (check == null)
                            {
                                //update
                                duplicateCheck.RequestTypeId = obj.RequestTypeId;
                                duplicateCheck.SubReasonID   = obj.SubReasonID;
                                duplicateCheck.ModifiedBy    = obj.CreatedBy;
                                duplicateCheck.ModifiedDate  = DateTime.Now;


                                context.Entry(duplicateCheck).State = System.Data.Entity.EntityState.Modified;
                                context.SaveChanges();

                                lst.Add(duplicateCheck);
                            }
                            else
                            {
                                return("Duplicate value not allowed");
                            }
                        }
                        else
                        {
                            var duplicateCheck1 = context.TblSAPReasonMasters.Where(x => x.IsActive == true && x.RequestTypeId == obj.RequestTypeId &&
                                                                                    x.SubReasonID == obj.SubReasonID).FirstOrDefault();
                            if (duplicateCheck1 == null)
                            {
                                //new entry
                                TblSAPReasonMaster ReasonMaster = new TblSAPReasonMaster()
                                {
                                    RequestTypeId = obj.RequestTypeId,
                                    SubReasonID   = obj.SubReasonID,

                                    IsActive    = true,
                                    CreatedBy   = obj.CreatedBy,
                                    CreatedDate = DateTime.Now,
                                };
                                context.Entry(ReasonMaster).State = System.Data.Entity.EntityState.Added;
                                context.SaveChanges();

                                lst.Add(duplicateCheck);
                            }
                            else
                            {
                                return("Duplicate value not allowed");
                            }
                        }
                    }
                    transaction.Complete();
                    transaction.Dispose();
                }
                return("Success : Reasons succssfully saved");
            }
        }
コード例 #9
0
        public static void UpdateRequestStatus(bool isNew, int Request_Id, string CreatedBy, string AssignedTo, int Active_Role, int Requested_Role, int CurrentStatus_Id, int FutureStatus_Id, string Remark)
        {
            using (var context = new SalesReturndbEntities())
            {
                using (TransactionScope T2 = new TransactionScope())
                {
                    int Approver_Id = 0;

                    if (isNew == true)
                    {
                        TblApproverHeader header = new TblApproverHeader()
                        {
                            Active_Role = Active_Role,
                            AssignedTo = AssignedTo,
                            Requested_Role = Requested_Role,
                            Request_Id = Request_Id ,
                            Status_Id = CurrentStatus_Id,
                            IsActive = true,
                            CreatedBy = CreatedBy,
                            CreatedDate = DateTime.Now,
                        };

                        context.Entry(header).State = EntityState.Added;
                        context.SaveChanges();

                        Approver_Id = header.Approver_Id;
                    }
                    else
                    {
                        var detail = context.TblApproverHeaders.Where(x => x.Request_Id == Request_Id).FirstOrDefault();

                        detail.Active_Role = Active_Role;
                        detail.AssignedTo = AssignedTo;
                        detail.Status_Id = CurrentStatus_Id;
                        detail.Requested_Role = Requested_Role;

                        detail.ModifiedBy = CreatedBy;
                        detail.ModifiedDate = DateTime.Now;
                        detail.IsActive = true;

                        context.Entry(detail).State = EntityState.Modified;
                        context.SaveChanges();

                        Approver_Id = detail.Approver_Id;
                    }

                    TblApproverDetail Appdetail = new TblApproverDetail()
                    {
                        Approver_Id = Approver_Id,
                        AssignedTo = AssignedTo,
                        Remark = Remark,
                        Role_Id = Active_Role,
                        Status_Id = CurrentStatus_Id,
                        CreatedBy = CreatedBy,
                        CreatedDate = DateTime.Now,
                        IsActive = true
                    };
                    context.Entry(Appdetail).State = EntityState.Added;
                    context.SaveChanges();

                    TblFutureStatu statu = new TblFutureStatu()
                    {
                        Request_ID = Request_Id,
                        EmployeeCode = AssignedTo,
                        Role = Requested_Role,
                        Status = FutureStatus_Id,
                        CreatedBy = CreatedBy,
                        CreatedDate = DateTime.Now,
                        IsActive = true
                    };

                    context.Entry(statu).State = EntityState.Added;
                    context.SaveChanges();

                    T2.Complete();
                    T2.Dispose();
                }
            }
        }