Example #1
0
        private void ListFactoryGetMaster()
        {
            if (this.FactoryID > 0)
            {
                ListFactoryDTS.ListFactoryDataTable masterDataTable = this.MasterTableAdapter.GetData(this.FactoryID);

                if (masterDataTable.Count > 0)
                {
                    this.ListFactoryMaster.StopTracking();

                    this.ListFactoryMaster.EntryDate = masterDataTable[0].EntryDate;

                    this.ListFactoryMaster.Description   = masterDataTable[0].Description;
                    this.ListFactoryMaster.LogoGenerator = masterDataTable[0].LogoGenerator;
                    this.ListFactoryMaster.Remarks       = masterDataTable[0].Remarks;

                    this.ListFactoryMaster.StartTracking();

                    this.ListFactoryMaster.Reset();

                    this.UserOrganization.UserID             = masterDataTable[0].UserID;
                    this.UserOrganization.UserOrganizationID = masterDataTable[0].UserOrganizationID;
                }
                else
                {
                    throw new System.ArgumentException("Insufficient get data");
                }
            }
            else
            {
                GlobalDefaultValue.Apply(this.ListFactoryMaster);
                this.ListFactoryMaster.EntryDate = DateTime.Today;
                this.ListFactoryMaster.Reset();
            }
        }
Example #2
0
        private bool SaveMaster(ref int factoryID)
        {
            ListFactoryDTS.ListFactoryDataTable masterDataTable;
            ListFactoryDTS.ListFactoryRow       masterRow;

            if (this.listFactoryMaster.FactoryID <= 0) //Add
            {
                masterDataTable = new ListFactoryDTS.ListFactoryDataTable();
                masterRow       = masterDataTable.NewListFactoryRow();
            }
            else //Edit
            {
                if (!this.SaveUndo(listFactoryMaster.FactoryID))
                {
                    throw new System.ArgumentException("Insufficient save", "Save undo");
                }
                masterDataTable = this.MasterTableAdapter.GetData(listFactoryMaster.FactoryID);
                if (masterDataTable.Count > 0)
                {
                    masterRow = masterDataTable[0];
                }
                else
                {
                    throw new System.ArgumentException("Insufficient save", "Get for edit");
                }
            }

            masterRow.EntryDate = DateTime.Now;

            masterRow.Description   = this.listFactoryMaster.Description;
            masterRow.LogoGenerator = this.listFactoryMaster.LogoGenerator;
            masterRow.Remarks       = this.listFactoryMaster.Remarks;

            masterRow.UserID             = this.UserOrganization.UserID;
            masterRow.UserOrganizationID = this.UserOrganization.UserOrganizationID;

            masterRow.EntryStatusID = this.listFactoryMaster.FactoryID <= 0 || (int)masterDataTable[0]["EntryStatusID"] == (int)GlobalEnum.EntryStatusID.IsNew ? (int)GlobalEnum.EntryStatusID.IsNew : (int)GlobalEnum.EntryStatusID.IsEdited;

            if (this.listFactoryMaster.FactoryID <= 0)
            {
                masterDataTable.AddListFactoryRow(masterRow);
            }

            int rowsAffected = this.MasterTableAdapter.Update(masterRow);

            factoryID = masterRow.FactoryID;

            return(rowsAffected == 1);
        }