コード例 #1
0
        private void ListLogoGetMaster()
        {
            if (this.LogoID > 0)
            {
                ListLogoDTS.ListLogoDataTable masterDataTable = this.MasterTableAdapter.GetData(this.LogoID);

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

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

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

                    this.ListLogoMaster.StartTracking();

                    this.ListLogoMaster.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.ListLogoMaster);
                this.ListLogoMaster.EntryDate = DateTime.Today;
                this.ListLogoMaster.Reset();
            }
        }
コード例 #2
0
        private bool SaveMaster(ref int logoID)
        {
            ListLogoDTS.ListLogoDataTable masterDataTable;
            ListLogoDTS.ListLogoRow       masterRow;

            if (this.listLogoMaster.LogoID <= 0) //Add
            {
                masterDataTable = new ListLogoDTS.ListLogoDataTable();
                masterRow       = masterDataTable.NewListLogoRow();
            }
            else //Edit
            {
                if (!this.SaveUndo(listLogoMaster.LogoID))
                {
                    throw new System.ArgumentException("Insufficient save", "Save undo");
                }
                masterDataTable = this.MasterTableAdapter.GetData(listLogoMaster.LogoID);
                if (masterDataTable.Count > 0)
                {
                    masterRow = masterDataTable[0];
                }
                else
                {
                    throw new System.ArgumentException("Insufficient save", "Get for edit");
                }
            }

            masterRow.EntryDate = DateTime.Now;

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

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

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

            if (this.listLogoMaster.LogoID <= 0)
            {
                masterDataTable.AddListLogoRow(masterRow);
            }

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

            logoID = masterRow.LogoID;

            return(rowsAffected == 1);
        }