Exemplo n.º 1
0
        public dynamic GetMachineSetupDetails(int?companyID, int?loggedUser, int?pageNumber, int?pageSize, int?IsPaging, int?MasterID, int?DetailsID)
        {
            dynamic result = null;

            try
            {
                string spQuery = string.Empty;
                using (_ctxObj = new ERP_Entities())
                {
                    var itemID               = MasterID;
                    var machineID            = DetailsID;
                    PrdDyingMachineSetup ent = (from machineSetup in _ctxObj.PrdDyingMachineSetups
                                                where machineSetup.ItemID == itemID &&
                                                machineSetup.MechineID == ((machineID == 0) ? machineSetup.MechineID : (long)machineID)
                                                select machineSetup).FirstOrDefault();

                    Hashtable ht = new Hashtable();
                    ht.Add("CompanyID", companyID);
                    ht.Add("LoggedUser", loggedUser);
                    ht.Add("MASTERID", MasterID);
                    ht.Add("DETAILSID", ent.SetupID.ToString());
                    spQuery = "[GET_DYINGMACHINESETUP]";
                    using (objectMachineSetupDetails = new dynamic_EF())
                    {
                        result = objectMachineSetupDetails.ExecuteQueryObjectType(spQuery, ht);
                    }
                    return(result);
                }
            }
            catch (Exception ex)
            {
                result = ex.Message.ToString();
                ex.ToString();
            }
            return(0);
        }
Exemplo n.º 2
0
        public string DelUpdateSetWiseMachineSetupMasterDetail(vmCmnParameters objcmnParam)
        {
            string result = string.Empty;

            using (var transaction = new TransactionScope())
            {
                GFactory_EF_PrdDyingMachineSetup       = new PrdDyingMachineSetup_EF();
                GFactory_EF_PrdDyingMachineSetupDetail = new PrdDyingMachineSetupDetail_EF();

                var Masteritem = new PrdDyingMachineSetup();
                var SetDetail  = new List <PrdDyingMachineSetupDetail>();

                //For Update Master Detail
                var SetMasterAll = GFactory_EF_PrdDyingMachineSetup.GetAll().Where(x => x.SetupID == objcmnParam.id);
                var SetDetailAll = GFactory_EF_PrdDyingMachineSetupDetail.GetAll().Where(x => x.SetupID == objcmnParam.id);
                //-------------------END----------------------

                try
                {
                    using (_ctxCmn = new ERP_Entities())
                    {
                        Masteritem           = SetMasterAll.First(x => x.SetupID == objcmnParam.id);
                        Masteritem.CompanyID = objcmnParam.loggedCompany;
                        Masteritem.DeleteBy  = objcmnParam.loggeduser;
                        Masteritem.DeleteOn  = DateTime.Now;
                        Masteritem.DeletePc  = HostService.GetIP();
                        Masteritem.IsDeleted = true;

                        foreach (PrdDyingMachineSetupDetail d in SetDetailAll.Where(d => d.SetupID == objcmnParam.id))
                        {
                            d.CompanyID = objcmnParam.loggedCompany;
                            d.DeleteBy  = objcmnParam.loggeduser;
                            d.DeleteOn  = DateTime.Now;
                            d.DeletePc  = HostService.GetIP();
                            d.IsDeleted = true;

                            SetDetail.Add(d);
                            //break;
                        }
                    }

                    if (Masteritem != null)
                    {
                        GFactory_EF_PrdDyingMachineSetup.Update(Masteritem);
                        GFactory_EF_PrdDyingMachineSetup.Save();
                    }
                    if (SetDetail != null && SetDetail.Count != 0)
                    {
                        GFactory_EF_PrdDyingMachineSetupDetail.UpdateList(SetDetail.ToList());
                        GFactory_EF_PrdDyingMachineSetupDetail.Save();
                    }

                    transaction.Complete();
                    result = "1";
                }
                catch (Exception e)
                {
                    result = "";
                    e.ToString();
                }
            }
            return(result);
        }
Exemplo n.º 3
0
        public string SaveUpdateSetWiseMachineSetupMasterDetail(vmItemSetSetup Master, List <vmItemSetSetup> Detail, vmCmnParameters objcmnParam)
        {
            string result = string.Empty;

            using (var transaction = new TransactionScope())
            {
                GFactory_EF_PrdDyingMachineSetup       = new PrdDyingMachineSetup_EF();
                GFactory_EF_PrdDyingMachineSetupDetail = new PrdDyingMachineSetupDetail_EF();
                long SetMasterId = 0, SetDetailId = 0, FirstDigit = 0, OtherDigits = 0; //string SetNo = "";

                var Masteritem = new PrdDyingMachineSetup();
                var SetDetail  = new List <PrdDyingMachineSetupDetail>();

                vmItemSetSetup item  = new vmItemSetSetup();
                vmItemSetSetup items = new vmItemSetSetup();
                //-------------------END----------------------

                if (Detail.Count() > 0)
                {
                    try
                    {
                        if (Master.SetupID == 0)
                        {
                            SetMasterId = Convert.ToInt16(GFactory_EF_PrdDyingMachineSetup.getMaxID("PrdDyingMachineSetup"));
                            SetDetailId = Convert.ToInt64(GFactory_EF_PrdDyingMachineSetupDetail.getMaxID("PrdDyingMachineSetupDetail"));
                            FirstDigit  = Convert.ToInt64(SetDetailId.ToString().Substring(0, 1));
                            OtherDigits = Convert.ToInt64(SetDetailId.ToString().Substring(1, SetDetailId.ToString().Length - 1));

                            Masteritem = new PrdDyingMachineSetup
                            {
                                SetupID   = SetMasterId,
                                Speed     = Master.Speed == null ? 0 : (decimal)Master.Speed,
                                KGPreMin  = Master.KGPreMin == null ? 0 : (decimal)Master.KGPreMin,
                                MechineID = (long)Master.MachineID,
                                Moiture   = Master.Moiture == null ? 0 : (decimal)Master.Moiture,
                                ItemID    = (long)Master.ItemID,

                                CompanyID = objcmnParam.loggedCompany,
                                CreateBy  = objcmnParam.loggeduser,
                                CreateOn  = DateTime.Now,
                                CreatePc  = HostService.GetIP(),
                                IsDeleted = false
                            };

                            for (int i = 0; i < Detail.Count(); i++)
                            {
                                item = Detail[i];

                                var Detailitem = new PrdDyingMachineSetupDetail
                                {
                                    SetupDetailID      = Convert.ToInt64(FirstDigit + "" + OtherDigits),
                                    SetupID            = SetMasterId,
                                    SQPress            = item.SQPress == null ? 0 : item.SQPress,
                                    Temp               = item.Temp == null ? 0 : item.Temp,
                                    MachineOperationID = (int)item.MachineOperationID,
                                    MachinePartID      = (int)item.MachinePartID,

                                    CompanyID = objcmnParam.loggedCompany,
                                    CreateBy  = objcmnParam.loggeduser,
                                    CreateOn  = DateTime.Now,
                                    CreatePc  = HostService.GetIP(),
                                    IsDeleted = false
                                };
                                //***************************************END*******************************************
                                SetDetail.Add(Detailitem);
                                OtherDigits++;
                            }
                        }
                        else
                        {
                            var SetMasterAll = GFactory_EF_PrdDyingMachineSetup.GetAll().Where(x => x.SetupID == Master.SetupID);
                            var SetDetailAll = GFactory_EF_PrdDyingMachineSetupDetail.GetAll().Where(x => x.SetupID == Master.SetupID);

                            Masteritem           = SetMasterAll.FirstOrDefault(x => x.SetupID == Master.SetupID);
                            Masteritem.Speed     = (decimal)Master.Speed;
                            Masteritem.KGPreMin  = (decimal)Master.KGPreMin;
                            Masteritem.MechineID = (long)Master.MachineID;
                            Masteritem.ItemID    = (long)Master.ItemID;
                            Masteritem.Moiture   = (decimal)Master.Moiture;

                            Masteritem.CompanyID = objcmnParam.loggedCompany;
                            Masteritem.UpdateBy  = objcmnParam.loggeduser;
                            Masteritem.UpdateOn  = DateTime.Now;
                            Masteritem.UpdatePc  = HostService.GetIP();
                            Masteritem.IsDeleted = false;

                            for (int i = 0; i < Detail.Count(); i++)
                            {
                                item = Detail[i];
                                foreach (PrdDyingMachineSetupDetail d in SetDetailAll.Where(d => d.SetupID == Master.SetupID && d.SetupDetailID == item.SetupDetailID))
                                {
                                    d.SQPress            = item.SQPress;
                                    d.Temp               = item.Temp;
                                    d.MachineOperationID = (int)item.MachineOperationID;
                                    d.MachinePartID      = (int)item.MachinePartID;

                                    d.CompanyID = objcmnParam.loggedCompany;
                                    d.CreateBy  = objcmnParam.loggeduser;
                                    d.CreateOn  = DateTime.Now;
                                    d.CreatePc  = HostService.GetIP();
                                    d.IsDeleted = false;

                                    SetDetail.Add(d);
                                    break;
                                }
                            }
                        }

                        if (Master.SetupID > 0)
                        {
                            if (Masteritem != null)
                            {
                                GFactory_EF_PrdDyingMachineSetup.Update(Masteritem);
                                GFactory_EF_PrdDyingMachineSetup.Save();
                            }
                            if (SetDetail != null && SetDetail.Count != 0)
                            {
                                GFactory_EF_PrdDyingMachineSetupDetail.UpdateList(SetDetail.ToList());
                                GFactory_EF_PrdDyingMachineSetupDetail.Save();
                            }
                        }
                        else
                        {
                            if (Masteritem != null)
                            {
                                GFactory_EF_PrdDyingMachineSetup.Insert(Masteritem);
                                GFactory_EF_PrdDyingMachineSetup.Save();
                                GFactory_EF_PrdDyingMachineSetup.updateMaxID("PrdDyingMachineSetup", Convert.ToInt64(SetMasterId));
                            }
                            if (SetDetail != null && SetDetail.Count != 0)
                            {
                                GFactory_EF_PrdDyingMachineSetupDetail.InsertList(SetDetail.ToList());
                                GFactory_EF_PrdDyingMachineSetupDetail.Save();
                                GFactory_EF_PrdDyingMachineSetupDetail.updateMaxID("PrdDyingMachineSetupDetail", Convert.ToInt64(FirstDigit + "" + (OtherDigits - 1)));
                            }
                        }

                        transaction.Complete();
                        result = "1";
                    }
                    catch (Exception e)
                    {
                        result = "";
                        e.ToString();
                    }
                }
                else
                {
                    result = "";
                    throw new Exception();
                }
            }
            return(result);
        }