コード例 #1
0
        private void btnOk_Click(object sender, EventArgs e)
        {
            inPar = null;
            //int countItem = 0;
            if (inparlist != null && inparlist.Count > 0)
            {
                foreach (var item in inparlist)
                {
                    if (txtIP_INT_NO.Text.Trim() == item.IP_INT_NO)
                    {
                        //countItem++;
                        if (_updataType == UpdataType.Add)
                        {
                            lbInfo.Text = $"IP_INT_NO ({item.IP_INT_NO}) is exist, please input again";
                            return;
                        }
                        else
                        {
                            if (IP_INT_NO_old != txtIP_INT_NO.Text.Trim())
                            {
                                lbInfo.Text = $"IP_INT_NO ({item.IP_INT_NO}) is exist, please input again";
                                return;
                            }
                        }
                    }
                }
            }
            if (txtIP_NAME.Text.Trim() == string.Empty)
            {
                lbInfo.Text = "IP_NAME is empty, please input title";
                return;
            }
            inPar           = new InterestedParty();
            inPar.No        = (maxNo + 1);
            inPar.IP_INT_NO = txtIP_INT_NO.Text.Trim().ToUpper();
            inPar.IP_NAME   = VnHelper.ConvertToUnSign(txtIP_NAME.Text.Trim()).ToUpper();

            inPar.IP_NAMETYPE = cboIP_NAMETYPE.Text.Trim();
            inPar.IP_WK_ROLE  = cboIP_WK_ROLE.Text.Trim();
            //inPar.WK_STATUS = cboWK_STATUS.Text.Trim();

            inPar.PER_OWN_SHR = numPER_OWN_SHR.Value;
            inPar.PER_COL_SHR = numPER_COL_SHR.Value;

            inPar.MEC_OWN_SHR = numMEC_OWN_SHR.Value;
            inPar.MEC_COL_SHR = numMEC_COL_SHR.Value;

            inPar.SP_SHR        = numSP_SHR.Value;
            inPar.TOTAL_MEC_SHR = numTOTAL_MEC_SHR.Value;

            inPar.SYN_OWN_SHR   = numSYN_OWN_SHR.Value;
            inPar.SYN_COL_SHR   = numSYN_COL_SHR.Value;
            inPar.Society       = txtSociety.Text.Trim().ToUpper();
            inPar.IP_NAME_LOCAL = txtIP_NAME_LOCAL.Text.Trim().ToUpper();
            inPar.CountUpdate++;
            inPar.LastUpdateAt = DateTime.Now;
            this.Close();
        }
コード例 #2
0
 private void DeleteToolStripMenuItem1_Click(object sender, EventArgs e)
 {
     try
     {
         int             maxNo = 0;
         InterestedParty inPar = null;
         if (_updataType == UpdataType.Add)
         {
             if (currenObjectCreate.InterestedParties.Count > 0)
             {
                 maxNo = int.Parse(dgvInterestedParties.CurrentRow.Cells["Nox"].Value.ToString());
                 inPar = currenObjectCreate.InterestedParties.Where(p => p.No == maxNo).FirstOrDefault();
             }
         }
         else
         {
             if (currenObjectUpdate.InterestedParties.Count > 0)
             {
                 maxNo = int.Parse(dgvInterestedParties.CurrentRow.Cells["Nox"].Value.ToString());
                 inPar = currenObjectUpdate.InterestedParties.Where(p => p.No == maxNo).FirstOrDefault();
             }
         }
         if (maxNo > 0)
         {
             DialogResult dr = MessageBox.Show("Are you sure delete?.", "DELETE Confirm", MessageBoxButtons.YesNoCancel,
                                               MessageBoxIcon.Information);
             if (dr == DialogResult.Yes)
             {
                 if (inPar != null)
                 {
                     if (_updataType == UpdataType.Add)
                     {
                         //dgvInterestedParties.Rows.Clear();
                         currenObjectCreate.InterestedParties.Remove(inPar);
                         dgvInterestedParties.DataSource = new List <InterestedParty>();
                         dgvInterestedParties.DataSource = currenObjectCreate.InterestedParties;
                         dgvInterestedParties.Invalidate();
                     }
                     else
                     {
                         //dgvInterestedParties.AutoSizeRowsMode = System.Windows.Forms.DataGridViewAutoSizeRowsMode.None;
                         //dgvInterestedParties.Rows.Clear();
                         currenObjectUpdate.InterestedParties.Remove(inPar);
                         dgvInterestedParties.DataSource = new List <InterestedParty>();
                         dgvInterestedParties.DataSource = currenObjectUpdate.InterestedParties;
                         dgvInterestedParties.Invalidate();
                     }
                 }
             }
         }
     }
     catch (Exception)
     {
         //int a = 1;
     }
 }
コード例 #3
0
 public frmInterestedParitesUpdate(UpdataType _updataType, int maxNo, InterestedParty inPar, List <InterestedParty> inparlist)
 {
     InitializeComponent();
     this.maxNo       = maxNo;
     this._updataType = _updataType;
     this.inPar       = inPar;
     this.inparlist   = inparlist;
     if (inPar != null)
     {
         IP_INT_NO_old = inPar.IP_INT_NO;
     }
 }
コード例 #4
0
 private void EditToolStripMenuItem1_Click(object sender, EventArgs e)
 {
     try
     {
         int                    maxNo     = 0;
         InterestedParty        inPar     = null;
         List <InterestedParty> inparlist = null;
         if (_updataType == UpdataType.Add)
         {
             if (currenObjectCreate.InterestedParties.Count > 0)
             {
                 maxNo     = int.Parse(dgvInterestedParties.CurrentRow.Cells["Nox"].Value.ToString());
                 inparlist = currenObjectCreate.InterestedParties;
                 inPar     = currenObjectCreate.InterestedParties.Where(p => p.No == maxNo).FirstOrDefault();
             }
         }
         else
         {
             if (currenObjectUpdate.InterestedParties.Count > 0)
             {
                 maxNo     = int.Parse(dgvInterestedParties.CurrentRow.Cells["Nox"].Value.ToString());
                 inparlist = currenObjectUpdate.InterestedParties;
                 inPar     = currenObjectUpdate.InterestedParties.Where(p => p.No == maxNo).FirstOrDefault();
             }
         }
         if (inPar != null)
         {
             frmInterestedParitesUpdate frm = new frmInterestedParitesUpdate(UpdataType.Edit, maxNo, inPar, inparlist);
             frm.ShowDialog();
             if (frm.inPar != null)
             {
                 if (_updataType == UpdataType.Add)
                 {
                     var item = currenObjectCreate.InterestedParties.Where(p => p.No == maxNo).FirstOrDefault();
                     if (item != null)
                     {
                         item.IP_INT_NO   = frm.inPar.IP_INT_NO;
                         item.IP_NAMETYPE = frm.inPar.IP_NAMETYPE;
                         item.IP_WK_ROLE  = frm.inPar.IP_WK_ROLE;
                         item.IP_NAME     = frm.inPar.IP_NAME;
                         //TODO 2020-10-02
                         //item.WK_STATUS = frm.inPar.WK_STATUS;
                         item.PER_OWN_SHR   = frm.inPar.PER_OWN_SHR;
                         item.PER_COL_SHR   = frm.inPar.PER_COL_SHR;
                         item.MEC_OWN_SHR   = frm.inPar.MEC_OWN_SHR;
                         item.MEC_COL_SHR   = frm.inPar.MEC_COL_SHR;
                         item.SP_SHR        = frm.inPar.SP_SHR;
                         item.TOTAL_MEC_SHR = frm.inPar.TOTAL_MEC_SHR;
                         item.SYN_OWN_SHR   = frm.inPar.SYN_OWN_SHR;
                         item.SYN_COL_SHR   = frm.inPar.SYN_COL_SHR;
                         item.Society       = frm.inPar.Society;
                         item.IP_NAME_LOCAL = frm.inPar.IP_NAME_LOCAL;
                     }
                     currenObjectCreate.InterestedParties = currenObjectCreate.InterestedParties.OrderBy(p => p.IP_INT_NO).ToList();
                     dgvInterestedParties.DataSource      = currenObjectCreate.InterestedParties;
                 }
                 else
                 {
                     var item = currenObjectUpdate.InterestedParties.Where(p => p.No == maxNo).FirstOrDefault();
                     if (item != null)
                     {
                         item.IP_INT_NO   = frm.inPar.IP_INT_NO;
                         item.IP_NAMETYPE = frm.inPar.IP_NAMETYPE;
                         item.IP_WK_ROLE  = frm.inPar.IP_WK_ROLE;
                         item.IP_NAME     = frm.inPar.IP_NAME;
                         //TODO 2020-10-02
                         //item.WK_STATUS = frm.inPar.WK_STATUS;
                         item.PER_OWN_SHR   = frm.inPar.PER_OWN_SHR;
                         item.PER_COL_SHR   = frm.inPar.PER_COL_SHR;
                         item.MEC_OWN_SHR   = frm.inPar.MEC_OWN_SHR;
                         item.MEC_COL_SHR   = frm.inPar.MEC_COL_SHR;
                         item.SP_SHR        = frm.inPar.SP_SHR;
                         item.TOTAL_MEC_SHR = frm.inPar.TOTAL_MEC_SHR;
                         item.SYN_OWN_SHR   = frm.inPar.SYN_OWN_SHR;
                         item.SYN_COL_SHR   = frm.inPar.SYN_COL_SHR;
                         item.Society       = frm.inPar.Society;
                         item.IP_NAME_LOCAL = frm.inPar.IP_NAME_LOCAL;
                     }
                     currenObjectUpdate.InterestedParties = currenObjectUpdate.InterestedParties.OrderBy(p => p.IP_INT_NO).ToList();
                     dgvInterestedParties.DataSource      = currenObjectUpdate.InterestedParties;
                 }
             }
         }
     }
     catch (Exception)
     {
         //throw;
     }
 }
コード例 #5
0
        /// <summary>
        ///  Create a InterestedParty
        /// </summary>
        /// <param name="currentUser"></param>
        /// <param name="user"></param>
        /// <param name="appID"></param>
        /// <param name="overrideID"></param>
        /// <param name="dc"></param>
        /// <param name="dataRepository"></param>
        /// <param name="uow"></param>
        public InterestedPartyVMDC CreateInterestedParty(string currentUser, string user, string appID, string overrideID, InterestedPartyDC dc, IRepository <InterestedParty> dataRepository, IUnitOfWork uow, IExceptionManager exceptionManager, IMappingService mappingService)
        {
            try
            {
                #region Parameter validation

                // Validate parameters
                if (string.IsNullOrEmpty(currentUser))
                {
                    throw new ArgumentOutOfRangeException("currentUser");
                }
                if (string.IsNullOrEmpty(user))
                {
                    throw new ArgumentOutOfRangeException("user");
                }
                if (string.IsNullOrEmpty(appID))
                {
                    throw new ArgumentOutOfRangeException("appID");
                }
                if (null == dc)
                {
                    throw new ArgumentOutOfRangeException("dc");
                }
                if (null == dataRepository)
                {
                    throw new ArgumentOutOfRangeException("dataRepository");
                }
                if (null == uow)
                {
                    throw new ArgumentOutOfRangeException("uow");
                }
                if (null == exceptionManager)
                {
                    throw new ArgumentOutOfRangeException("exceptionManager");
                }
                if (null == mappingService)
                {
                    throw new ArgumentOutOfRangeException("mappingService");
                }

                #endregion

                using (uow)
                {
                    // Create a new ID for the InterestedParty item
                    dc.Code = Guid.NewGuid();

                    // Map data contract to model
                    InterestedParty destination = mappingService.Map <InterestedPartyDC, InterestedParty>(dc);

                    // Add the new item
                    dataRepository.Add(destination);

                    // Commit unit of work
                    uow.Commit();

                    // Map model back to data contract to return new row id.
                    dc = mappingService.Map <InterestedParty, InterestedPartyDC>(destination);
                }

                // Create aggregate data contract
                InterestedPartyVMDC returnObject = new InterestedPartyVMDC();

                // Add new item to aggregate
                returnObject.InterestedPartyItem = dc;

                return(returnObject);
            }
            catch (Exception e)
            {
                //Prevent exception from propogating across the service interface
                exceptionManager.ShieldException(e);

                return(null);
            }
        }
コード例 #6
0
        /// <summary>
        /// Retrieve a InterestedParty with associated lookups
        /// </summary>
        /// <param name="currentUser"></param>
        /// <param name="user"></param>
        /// <param name="appID"></param>
        /// <param name="overrideID"></param>
        /// <param name="code"></param>
        /// <param name="dataRepository"></param>
        /// <param name="uow"></param>
        /// <returns></returns>
        public InterestedPartyVMDC GetInterestedParty(string currentUser, string user, string appID, string overrideID, string code, IUnitOfWork uow, IRepository <InterestedParty> dataRepository
                                                      , IExceptionManager exceptionManager, IMappingService mappingService)

        {
            try
            {
                #region Parameter validation

                // Validate parameters
                if (string.IsNullOrEmpty(currentUser))
                {
                    throw new ArgumentOutOfRangeException("currentUser");
                }
                if (string.IsNullOrEmpty(user))
                {
                    throw new ArgumentOutOfRangeException("user");
                }
                if (string.IsNullOrEmpty(appID))
                {
                    throw new ArgumentOutOfRangeException("appID");
                }
                if (null == dataRepository)
                {
                    throw new ArgumentOutOfRangeException("dataRepository");
                }
                if (null == uow)
                {
                    throw new ArgumentOutOfRangeException("uow");
                }
                if (null == exceptionManager)
                {
                    throw new ArgumentOutOfRangeException("exceptionManager");
                }
                if (null == mappingService)
                {
                    throw new ArgumentOutOfRangeException("mappingService");
                }

                #endregion

                using (uow)
                {
                    InterestedPartyDC destination = null;

                    // If code is null then just return supporting lists
                    if (!string.IsNullOrEmpty(code))
                    {
                        // Convert code to Guid
                        Guid codeGuid = Guid.Parse(code);

                        // Retrieve specific InterestedParty
                        InterestedParty dataEntity = dataRepository.Single(x => x.Code == codeGuid);

                        // Convert to data contract for passing through service interface
                        destination = mappingService.Map <InterestedParty, InterestedPartyDC>(dataEntity);
                    }



                    // Create aggregate contract
                    InterestedPartyVMDC returnObject = new InterestedPartyVMDC();

                    returnObject.InterestedPartyItem = destination;

                    return(returnObject);
                }
            }
            catch (Exception e)
            {
                //Prevent exception from propogating across the service interface
                exceptionManager.ShieldException(e);

                return(null);
            }
        }
コード例 #7
0
        /// <summary>
        /// Update a InterestedParty
        /// </summary>
        /// <param name="currentUser"></param>
        /// <param name="user"></param>
        /// <param name="appID"></param>
        /// <param name="overrideID"></param>
        /// <param name="code"></param>
        /// <param name="lockID"></param>
        /// <param name="dataRepository"></param>
        /// <param name="uow"></param>
        public void DeleteInterestedParty(string currentUser, string user, string appID, string overrideID, string code, string lockID, IRepository <InterestedParty> dataRepository, IUnitOfWork uow, IExceptionManager exceptionManager, IMappingService mappingService)
        {
            try
            {
                #region Parameter validation

                // Validate parameters
                if (string.IsNullOrEmpty(currentUser))
                {
                    throw new ArgumentOutOfRangeException("currentUser");
                }
                if (string.IsNullOrEmpty(user))
                {
                    throw new ArgumentOutOfRangeException("user");
                }
                if (string.IsNullOrEmpty(appID))
                {
                    throw new ArgumentOutOfRangeException("appID");
                }
                if (string.IsNullOrEmpty(code))
                {
                    throw new ArgumentOutOfRangeException("code");
                }
                if (string.IsNullOrEmpty(lockID))
                {
                    throw new ArgumentOutOfRangeException("lockID");
                }
                if (null == dataRepository)
                {
                    throw new ArgumentOutOfRangeException("dataRepository");
                }
                if (null == uow)
                {
                    throw new ArgumentOutOfRangeException("uow");
                }
                if (null == exceptionManager)
                {
                    throw new ArgumentOutOfRangeException("exceptionManager");
                }
                if (null == mappingService)
                {
                    throw new ArgumentOutOfRangeException("mappingService");
                }

                #endregion

                using (uow)
                {
                    // Convert string to guid
                    Guid codeGuid = Guid.Parse(code);

                    // Find item based on ID
                    InterestedParty dataEntity = dataRepository.Single(x => x.Code == codeGuid);

                    // Delete the item
                    dataRepository.Delete(dataEntity);

                    // Commit unit of work
                    uow.Commit();
                }
            }
            catch (Exception e)
            {
                //Prevent exception from propogating across the service interface
                exceptionManager.ShieldException(e);
            }
        }
コード例 #8
0
 private void btnCancel_Click(object sender, EventArgs e)
 {
     inPar = null;
     this.Close();
 }