private void addToolStripMenuItem1_Click(object sender, EventArgs e) { try { List <InterestedParty> inparlist = null; int maxNo = 0; if (_updataType == UpdataType.Add) { if (currenObjectCreate.InterestedParties.Count > 0) { inparlist = currenObjectCreate.InterestedParties; var item = currenObjectCreate.InterestedParties.OrderByDescending(p => p.No).FirstOrDefault(); if (item != null) { maxNo = item.No; } } } else { if (currenObjectUpdate.InterestedParties.Count > 0) { inparlist = currenObjectUpdate.InterestedParties; var item = currenObjectUpdate.InterestedParties.OrderByDescending(p => p.No).FirstOrDefault(); if (item != null) { maxNo = item.No; } } } frmInterestedParitesUpdate frm = new frmInterestedParitesUpdate(UpdataType.Add, maxNo, null, inparlist); frm.ShowDialog(); if (frm.inPar != null) { if (_updataType == UpdataType.Add) { currenObjectCreate.InterestedParties.Add(frm.inPar); currenObjectCreate.InterestedParties = currenObjectCreate.InterestedParties.OrderBy(p => p.IP_INT_NO).ToList(); dgvInterestedParties.DataSource = currenObjectCreate.InterestedParties; } else { currenObjectUpdate.InterestedParties.Add(frm.inPar); currenObjectUpdate.InterestedParties = currenObjectUpdate.InterestedParties.OrderBy(p => p.IP_INT_NO).ToList(); dgvInterestedParties.DataSource = currenObjectUpdate.InterestedParties; } } } catch (Exception) { //throw; } }
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; } }