Ejemplo n.º 1
0
        public bool InsertDDCIInfo(string varOldCIref, string varNewCIref)
        {
            List <DDCI_INFO> lstOldDDCI  = new List <DDCI_INFO>();
            DDCI_INFO        ddciinfonew = new DDCI_INFO();
            DDCI_INFO        ddciinfoold = new DDCI_INFO();
            CultureInfo      provider    = CultureInfo.InvariantCulture;


            try
            {
                lstOldDDCI = (from row in DB.DDCI_INFO
                              where (row.DELETE_FLAG == false || row.DELETE_FLAG == null) &&
                              row.CI_REFERENCE.Trim() == varOldCIref.Trim()
                              select row).ToList <DDCI_INFO>();


                if (lstOldDDCI.Count > 0)
                {
                    ddciinfonew = new DDCI_INFO();
                    ddciinfoold = lstOldDDCI[0];
                    ddciinfonew = ddciinfoold.DeepCopy();
                    ddciinfonew.CI_REFERENCE      = varNewCIref;
                    ddciinfonew.IDPK              = 0;
                    ddciinfonew.CUST_DWG_NO       = "";
                    ddciinfonew.FR_CS_DATE        = null;
                    ddciinfonew.CUST_DWG_NO_ISSUE = "";
                    ddciinfonew.ENQU_RECD_ON      = null;
                    ddciinfonew.FR_CS_DATE        = serverDate;
                    ddciinfonew.ROWID             = Guid.NewGuid();
                    ddciinfonew.ENQU_RECD_ON      = DateTime.ParseExact(varNewCIref.Substring(5, 2) + "/" +
                                                                        varNewCIref.Substring(3, 2) + "/" +
                                                                        varNewCIref.Substring(1, 2), "dd/MM/yy", provider);
                    ddciinfonew.UPDATED_BY   = null;
                    ddciinfonew.UPDATED_DATE = null;
                    ddciinfonew.ENTERED_BY   = userInformation.UserName;
                    ddciinfonew.ENTERED_DATE = serverDateTime;
                    DB.DDCI_INFO.InsertOnSubmit(ddciinfonew);
                    DB.SubmitChanges();
                }
                return(true);
            }
            catch (System.Data.Linq.ChangeConflictException)
            {
                DB.ChangeConflicts.ResolveAll(System.Data.Linq.RefreshMode.KeepChanges);
            }
            catch (Exception ex)
            {
                throw ex.LogException();
            }
            return(true);
        }
Ejemplo n.º 2
0
        private void SaveSubmitCommand()
        {
            if (!OldActiveEntity.IsNotNullOrEmpty())
            {
                return;
            }
            if (!NewActiveEntity.IsNotNullOrEmpty())
            {
                return;
            }

            if (!OldActiveEntity.CI_REFERENCE.IsNotNullOrEmpty())
            {
                ShowInformationMessage(PDMsg.NotEmpty("Old CI Reference Number"));
                return;
            }

            if (!NewActiveEntity.CI_REFERENCE.IsNotNullOrEmpty())
            {
                ShowInformationMessage(PDMsg.NotEmpty("New CI Reference Number"));
                return;
            }

            if (OldActiveEntity.CI_REFERENCE.Trim() == NewActiveEntity.CI_REFERENCE.Trim())
            {
                ShowInformationMessage("CI Reference Numbers should not be same");
                return;
            }

            string           message;
            List <DDCI_INFO> lstResult = null;

            if (!bll.IsValidCIReferenceNumber(OldActiveEntity, OperationMode.Edit, out message) &&
                message.IsNotNullOrEmpty() && !(message.IndexOf("already exists") >= 0))
            {
                //ShowInformationMessage(message);
                //return;

                lstResult = (from row in bll.GetEntitiesByCIReferenceNumber(OldActiveEntity)
                             select row).ToList <DDCI_INFO>();

                if (lstResult.IsNotNullOrEmpty() && lstResult.Count == 0)
                {
                    ShowInformationMessage(PDMsg.DoesNotExists("Old CI Reference"));
                    return;
                }
            }

            lstResult = (from row in bll.GetEntitiesByCIReferenceNumber(OldActiveEntity)
                         select row).ToList <DDCI_INFO>();

            if (lstResult.IsNotNullOrEmpty() && lstResult.Count == 0)
            {
                ShowInformationMessage(PDMsg.DoesNotExists("Old CI Reference"));
                return;
            }

            lstResult = (from row in bll.GetEntitiesByCIReferenceNumber(NewActiveEntity)
                         select row).ToList <DDCI_INFO>();

            if (lstResult.IsNotNullOrEmpty() && lstResult.Count > 0)
            {
                message = PDMsg.AlreadyExists("CI Reference Number");
                message = message.IndexOf("already exists") >= 0 ?
                          "CI Reference Number " + NewActiveEntity.CI_REFERENCE + " already exists.\r\nEnter/Select another CI Reference Number" :
                          message;
                ShowInformationMessage(message);
                return;
            }

            string outMessage;

            if (!bll.IsValidCIReferenceNumber(NewActiveEntity, ActionMode, out outMessage) && outMessage.IsNotNullOrEmpty())
            {
                ShowInformationMessage(outMessage);
                return;
            }

            if (OldActiveEntity.RM_COST > 9999999999.99m)
            {
                ShowInformationMessage(PDMsg.NotExceeds("Cost for 100 Pcs", "9999999999.99"));
                return;
            }

            if (OldActiveEntity.FINAL_COST > 9999999999.99m)
            {
                ShowInformationMessage(PDMsg.NotExceeds("Cost for " + OldActiveEntity.NO_OF_PCS + " Pcs", "9999999999.99"));
                return;
            }

            if (OldActiveEntity.REALISATION > 99999999.99m)
            {
                ShowInformationMessage(PDMsg.NotExceeds("Realisation", "99999999.99"));
                return;
            }

            try
            {
                //List<DDCI_INFO> lstResult = null;
                List <DDCOST_PROCESS_DATA> lstAssociationEntity = null;

                bool isExecuted = false;
                switch (ActionMode)
                {
                case OperationMode.AddNew:
                    #region Add Operation

                    foreach (DDCOST_PROCESS_DATA associationEntity in OldActiveEntity.DDCOST_PROCESS_DATA)
                    {
                        OldActiveEntity.DDCOST_PROCESS_DATA.Remove(associationEntity);
                    }

                    string   newCIReferenceNumber = NewActiveEntity.CI_REFERENCE;
                    DateTime?newENQU_RECD_ON      = NewActiveEntity.ENQU_RECD_ON;
                    string   newZONE_CODE         = NewActiveEntity.ZONE_CODE;

                    DDCI_INFO activeEntity = OldActiveEntity.DeepCopy <DDCI_INFO>();
                    activeEntity.IDPK         = -99999;
                    activeEntity.CI_REFERENCE = newCIReferenceNumber;
                    activeEntity.ENQU_RECD_ON = newENQU_RECD_ON;
                    activeEntity.ZONE_CODE    = newZONE_CODE;

                    activeEntity.CUST_DWG_NO       = null;
                    activeEntity.CUST_DWG_NO_ISSUE = null;
                    activeEntity.FR_CS_DATE        = bll.ServerDateTime();

                    string syear = newCIReferenceNumber.Substring(1, 2).ToIntValue() == 0 ?
                                   "20" + newCIReferenceNumber.Substring(1, 2) : newCIReferenceNumber.Substring(1, 2);

                    string smonth = newCIReferenceNumber.Substring(3, 2);
                    string sday   = newCIReferenceNumber.Substring(5, 2);

                    try
                    {
                        DateTime receivedOn = new DateTime(syear.ToIntValue(), smonth.ToIntValue(), sday.ToIntValue());
                        activeEntity.ENQU_RECD_ON = receivedOn;
                    }
                    catch (Exception ex)
                    {
                        throw ex.LogException();
                    }

                    foreach (DDCOST_PROCESS_DATA associationEntity in activeEntity.DDCOST_PROCESS_DATA)
                    {
                        activeEntity.DDCOST_PROCESS_DATA.Remove(associationEntity);
                    }

                    isExecuted = bll.Update <DDCI_INFO>(new List <DDCI_INFO>()
                    {
                        activeEntity
                    });

                    if (isExecuted)
                    {
                        activeEntity = (from row in bll.GetEntitiesByCIReferenceNumber(activeEntity)
                                        select row).SingleOrDefault <DDCI_INFO>();
                        if (activeEntity.IsNotNullOrEmpty())
                        {
                            lstAssociationEntity = (from row in bll.GetCostDetails(OldActiveEntity)
                                                    select new DDCOST_PROCESS_DATA()
                            {
                                CI_REFERENCE = newCIReferenceNumber,
                                SNO = Convert.ToDecimal(row.SNO),
                                OPERATION_NO = Convert.ToDecimal(row.OPERATION_NO),
                                OPERATION = row.OPERATION,
                                COST_CENT_CODE = row.COST_CENT_CODE,
                                OUTPUT = row.OUTPUT,
                                VAR_COST = row.VAR_COST,
                                FIX_COST = row.FIX_COST,
                                SPL_COST = row.SPL_COST,
                                UNIT_OF_MEASURE = row.UNIT_OF_MEASURE,
                                TOTAL_COST = row.TOTAL_COST,
                                IDPK = -99999,
                                CI_INFO_FK = activeEntity.IDPK,
                                ROWID = Guid.NewGuid(),
                                PROCESS_CODE = Convert.ToDecimal(row.PROCESS_CODE),
                            }).ToList <DDCOST_PROCESS_DATA>();
                            if (lstAssociationEntity.IsNotNullOrEmpty() && lstAssociationEntity.Count == 0)
                            {
                                ShowInformationMessage("No Process Data to Copy");
                            }
                            else
                            {
                                isExecuted = bll.Update <DDCOST_PROCESS_DATA>(lstAssociationEntity);
                            }

                            List <DDSHAPE_DETAILS> lstFinishWeightCalculation = null;
                            lstFinishWeightCalculation = (from row in bll.GetShapeDetails(OldActiveEntity)
                                                          select new DDSHAPE_DETAILS()
                            {
                                CI_REFERENCE = newCIReferenceNumber,
                                SHAPE_CODE = row.SHAPE_CODE,
                                WEIGHT_OPTION = row.WEIGHT_OPTION,
                                HEAD1 = row.HEAD1,
                                VAL1 = row.VAL1,
                                HEAD2 = row.HEAD2,
                                VAL2 = row.VAL2,
                                HEAD3 = row.HEAD3,
                                VAL3 = row.VAL3,
                                VOLUME = row.VOLUME,
                                SIGN = row.SIGN,
                                SNO = row.SNO,
                                ROWID = row.ROWID,
                                IDPK = -99999,
                                CIREF_NO_FK = activeEntity.IDPK,
                            }).ToList <DDSHAPE_DETAILS>();
                            if (lstFinishWeightCalculation.IsNotNullOrEmpty() && lstFinishWeightCalculation.Count == 0)
                            {
                                ShowInformationMessage("No Weight Calculation Data to Copy");
                            }
                            else
                            {
                                Progress.ProcessingText = PDMsg.ProgressUpdateText;
                                Progress.Start();
                                isExecuted = bll.Update <DDSHAPE_DETAILS>(lstFinishWeightCalculation);
                                Progress.End();
                            }
                            if (isExecuted)
                            {
                                ShowInformationMessage(PDMsg.SavedSuccessfully);
                                NewActiveEntity = activeEntity.DeepCopy <DDCI_INFO>();
                                NewActiveEntity.CI_REFERENCE = string.Empty;
                                NewActiveEntity.ENQU_RECD_ON = newENQU_RECD_ON;
                                NewActiveEntity.ZONE_CODE    = newZONE_CODE;
                            }
                        }
                    }
                    #endregion
                    break;

                case OperationMode.Edit:
                    //#region Update Operation
                    //lstResult = (from row in bll.DB.DDCI_INFO
                    //             where row.CUST_DWG_NO == ActiveEntity.CUST_DWG_NO
                    //             select row).ToList<DDCI_INFO>();

                    //if (lstResult.IsNotNullOrEmpty() && lstResult.Count > 1)
                    //{
                    //    ShowInformationMessage("Customer Drawing Number already exists");
                    //    return;
                    //}

                    //lstStandardNotes = (from row in StandardNotes.ToTable().AsEnumerable()
                    //                    select new DDSTD_NOTES()
                    //                    {
                    //                        SNO = Convert.ToDecimal(row.Field<string>("SNO")),
                    //                        STD_NOTES = row.Field<string>("STD_NOTES"),
                    //                        ROWID = Guid.NewGuid(),
                    //                    }
                    //    ).ToList<DDSTD_NOTES>();

                    //isExecuted = bll.Update<DDSTD_NOTES>(lstStandardNotes);

                    //foreach (DDCOST_PROCESS_DATA associationEntity in ActiveEntity.DDCOST_PROCESS_DATA)
                    //{
                    //    ActiveEntity.DDCOST_PROCESS_DATA.Remove(associationEntity);
                    //}
                    //lstAssociationEntity = (from row in CostDetails.ToTable().AsEnumerable()
                    //                        select new DDCOST_PROCESS_DATA()
                    //                        {
                    //                            CI_REFERENCE = ActiveEntity.CI_REFERENCE,
                    //                            SNO = Convert.ToDecimal(row.Field<string>("SNO")),
                    //                            OPERATION_NO = Convert.ToDecimal(row.Field<string>("OPERATION_NO")),
                    //                            OPERATION = row.Field<string>("OPERATION"),
                    //                            COST_CENT_CODE = row.Field<string>("COST_CENT_CODE"),
                    //                            OUTPUT = Convert.ToDecimal(row.Field<string>("OUTPUT")),
                    //                            VAR_COST = Convert.ToDecimal(row.Field<string>("VAR_COST")),
                    //                            FIX_COST = Convert.ToDecimal(row.Field<string>("FIX_COST")),
                    //                            SPL_COST = Convert.ToDecimal(row.Field<string>("SPL_COST")),
                    //                            UNIT_OF_MEASURE = row.Field<string>("UNIT_OF_MEASURE"),
                    //                            TOTAL_COST = Convert.ToDecimal(row.Field<string>("TOTAL_COST")),
                    //                            IDPK = Convert.ToInt32(row.Field<string>("IDPK")),
                    //                            CI_INFO_FK = ActiveEntity.IDPK,
                    //                            ROWID = row.Field<string>("ROWID").ToGuidValue(),
                    //                        }).ToList<DDCOST_PROCESS_DATA>();

                    //isExecuted = bll.Update<DDCOST_PROCESS_DATA>(lstAssociationEntity);

                    //if (isExecuted)
                    //{

                    //    isExecuted = bll.Update<DDCI_INFO>(new List<DDCI_INFO>() { ActiveEntity });
                    //    if (isExecuted)
                    //    {
                    //        ShowInformationMessage("Records saved successfully");
                    //    }
                    //}
                    //#endregion
                    break;

                case OperationMode.Delete:
                    break;
                }
            }
            catch (Exception ex)
            {
                throw ex.LogException();
            }
            ActionMode = OperationMode.AddNew;
            //CIReferenceDataSource = bll.GetCIReferenceNumber().ToDataTable<V_CI_REFERENCE_NUMBER>().DefaultView;
            ChangeRights();
            Reload = true;
            CloseAction();
        }
Ejemplo n.º 3
0
 private void CopyData()
 {
     try
     {
         bool   blnok       = false;
         string varOldCIref = "";
         FeasibleReportAndCostSheet frcs;
         Window           win          = new Window();
         DDCI_INFO        activeEntity = new DDCI_INFO();
         DDCI_INFO        getEntity    = new DDCI_INFO();
         List <DDCI_INFO> lstEntity    = new List <DDCI_INFO>();
         if (SelectedCostSheet == null)
         {
             Message = "CI Reference should be Selected";
             return;
         }
         getEntity.IDPK = SelectedCostSheet["CI_INFO_PK"].ToValueAsString().ToIntValue();
         frcs           = new FeasibleReportAndCostSheet(_userInformation);
         lstEntity      = frcs.GetEntitiesByPrimaryKey(getEntity);
         if (lstEntity.Count == 0)
         {
             return;
         }
         activeEntity = lstEntity[0];
         frmCopyCIReference userControl = new frmCopyCIReference(_userInformation, win, activeEntity.DeepCopy <DDCI_INFO>(), OperationMode.AddNew);
         win.Title                 = "Copy Data";
         win.Content               = userControl;
         win.Height                = userControl.Height + 50;
         win.Width                 = userControl.Width + 10;
         win.ShowInTaskbar         = true;
         win.WindowStartupLocation = WindowStartupLocation.CenterScreen;
         win.WindowState           = WindowState.Normal;
         win.ResizeMode            = ResizeMode.NoResize;
         win.ShowDialog();
         if (userControl.Vm.Reload == true)
         {
             SearchCostSheet();
             SelectedCostSheet = dvCostSheetSearch[0];
             NotifyPropertyChanged("SelectedCostSheet");
         }
         //CIReferenceDataSource = bll.GetCIReferenceNumber().ToDataTable<V_CI_REFERENCE_NUMBER>().DefaultView;
     }
     catch (Exception ex)
     {
         throw ex.LogException();
     }
 }