示例#1
0
 /// <summary> 添加配件信息到列表的事件
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void cmsPurchaseAccessoriesAdd_Click(object sender, EventArgs e)
 {
     try
     {
         //frmParts frm = new frmParts();
         frmPartsByYuTong frm = new frmPartsByYuTong();
         DialogResult result = frm.ShowDialog();
         if (result == DialogResult.OK)
         {
             string PartsCode = frm.PartsCode;
             if (gvPurchaseList.Rows.Count > 0)
             {
                 foreach (DataGridViewRow dr in gvPurchaseList.Rows)
                 {
                     if (dr.Cells["parts_code"].Value == null)
                     {
                         continue;
                     }
                     string relation_order = dr.Cells["relation_order"].Value == null ? "" : dr.Cells["relation_order"].Value.ToString();
                     if (dr.Cells["parts_code"].Value.ToString() == PartsCode && relation_order == "")
                     {
                         MessageBoxEx.Show("该配件信息已经存在与列表中,不能再次添加!");
                         return;
                     }
                 }
             }
             DataTable dt = GetAccessoriesByCode(PartsCode);
             if (dt == null || dt.Rows.Count == 0)
             {
                 return;
             }
             foreach (DataRow dr in dt.Rows)
             {
                 //int rowsindex = gvPurchaseList.Rows.Add();
                 int rowsindex = gvPurchaseList.Rows.Count - 1;
                 DataGridViewRow dgvr = gvPurchaseList.Rows[rowsindex];
                 GetGridViewRowByDr(dgvr, dr, "",rowsindex, "Add");
             }
             if (dt != null && dt.Rows.Count > 0)
             {
                 gvPurchaseList.Rows.Add(1);
             }
         }
     }
     catch (Exception ex)
     { }
     finally
     { oldindex = -1; }
 }
示例#2
0
 /// <summary> 编辑配件列表中的配件信息
 /// </summary>
 void EditPartsInfo()
 {
     if (oldindex > -1)
     {
         try
         {
             frmPartsByYuTong frm = new frmPartsByYuTong();
             DialogResult result = frm.ShowDialog();
             if (result == DialogResult.OK)
             {
                 string PartsCode = frm.PartsCode;
                 if (gvPurchaseList.Rows.Count > 0)
                 {
                     foreach (DataGridViewRow dr in gvPurchaseList.Rows)
                     {
                         if (dr.Cells["parts_code"].Value != null)
                         {
                             string relation_order = dr.Cells["relation_order"].Value == null ? "" : dr.Cells["relation_order"].Value.ToString();
                             if (dr.Cells["parts_code"].Value.ToString() == PartsCode && relation_order == "")
                             {
                                 MessageBoxEx.Show("该配件信息已经存在与列表中,不能再次添加!");
                                 return;
                             }
                         }
                     }
                 }
                 DataGridViewRow dgvr = gvPurchaseList.Rows[oldindex];
                 DataTable dt = GetAccessoriesByCode(PartsCode);
                 foreach (DataRow dr in dt.Rows)
                 {
                     GetGridViewRowByDr(dgvr, dr, "", oldindex, "Edit");
                 }
                 if (gvPurchaseList.Rows.Count - 1 == oldindex)
                 {
                     gvPurchaseList.Rows.Add(1);
                 }
             }
         }
         catch (Exception ex)
         { }
         finally
         { oldindex = -1; }
     }
 }