コード例 #1
0
ファイル: ListCategoryBLL.cs プロジェクト: Proerp/STS07JUL
        private void ListCategoryGetMaster()
        {
            if (this.CategoryID > 0)
            {
                ListCategoryDTS.ListCategoryDataTable masterDataTable = this.MasterTableAdapter.GetData(this.CategoryID);

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

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

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

                    this.ListCategoryMaster.StartTracking();

                    this.ListCategoryMaster.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.ListCategoryMaster);
                this.ListCategoryMaster.EntryDate = DateTime.Today;
                this.ListCategoryMaster.Reset();
            }
        }
コード例 #2
0
ファイル: ListCategoryBLL.cs プロジェクト: Proerp/STS07JUL
        private bool SaveMaster(ref int categoryID)
        {
            ListCategoryDTS.ListCategoryDataTable masterDataTable;
            ListCategoryDTS.ListCategoryRow       masterRow;

            if (this.listCategoryMaster.CategoryID <= 0) //Add
            {
                masterDataTable = new ListCategoryDTS.ListCategoryDataTable();
                masterRow       = masterDataTable.NewListCategoryRow();
            }
            else //Edit
            {
                if (!this.SaveUndo(listCategoryMaster.CategoryID))
                {
                    throw new System.ArgumentException("Insufficient save", "Save undo");
                }
                masterDataTable = this.MasterTableAdapter.GetData(listCategoryMaster.CategoryID);
                if (masterDataTable.Count > 0)
                {
                    masterRow = masterDataTable[0];
                }
                else
                {
                    throw new System.ArgumentException("Insufficient save", "Get for edit");
                }
            }

            masterRow.EntryDate = DateTime.Now;

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

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

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

            if (this.listCategoryMaster.CategoryID <= 0)
            {
                masterDataTable.AddListCategoryRow(masterRow);
            }

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

            categoryID = masterRow.CategoryID;

            return(rowsAffected == 1);
        }