private void button4_Click(object sender, EventArgs e) { string site=cmb_site.SelectedValue.ToString(); string partno=cmb_partno.Text.Trim().ToString(); string partspec=cmb_partname.Text.Trim().ToString(); string parttype = tb_type.Text.Trim().ToString(); string partmat = tb_mat.Text.Trim().ToString(); string partlevel = tb_level.Text.Trim().ToString(); string partcert = tb_cert.Text.Trim().ToString(); string purchasec = tb_pc.Text.Trim().ToString(); string spec1 = tb_spec1.Text.Trim().ToString(); string spec2 = tb_spec2.Text.Trim().ToString(); string spec3 = tb_spec3.Text.Trim().ToString(); string spec4 = tb_spec4.Text.Trim().ToString(); string partunit = tb_unit.Text.Trim().ToString(); string partunitdestiny = tb_unitdestiny.Text.Trim().ToString(); string partdestinyunit = txt_destinyunit.Text.Trim().ToString(); //if (ProjectId == string.Empty) //{ // MessageBox.Show("��ѡ����Ŀ��"); // return; //} if (partno == string.Empty) { MessageBox.Show("����д�����ţ�"); return; } if (Part.Exist(partno)) { MessageBox.Show("���������Ѿ����ڣ����飡"); return; } if (partspec == string.Empty) { MessageBox.Show("����д������"); return; } if (parttype == string.Empty) { MessageBox.Show("����д������ͣ�"); return; } if (partmat == string.Empty) { MessageBox.Show("����д������ʣ�"); return; } if (partcert == string.Empty) { MessageBox.Show("����д���֤�飡"); return; } if (partlevel == string.Empty) { MessageBox.Show("����д����ȼ���"); return; } try { DataSet unitds=PartParameter.QueryPartPara("select name from mm_unit_tab"); //string partno = dgv1.Rows[i].Cells["�����"].Value.ToString().Trim(); //PartParameter pp = PartParameter.Find(ProjectId, partno, site, LoginUser); Part ppn = new Part(); ppn.PART_NO = partno; ppn.CONTRACT = site; ppn.PARENTID = int.Parse(activity); ppn.PART_CERT = partcert; if (partunitdestiny!=string.Empty) ppn.PART_UNITDENSITY = decimal.Parse(partunitdestiny); if (partdestinyunit != string.Empty) ppn.PART_DENSITYUNIT = partdestinyunit; ppn.PART_LEVEL = partlevel; ppn.PART_SPEC = partspec; ppn.PART_SPEC1 = spec1; ppn.PART_SPEC2 = spec2; ppn.PART_SPEC3 = spec3; ppn.PART_SPEC4 = spec4; ppn.CREATOR = LoginUser; ppn.PART_UNIT = partunit; ppn.PART_MAT = partmat; ppn.PART_TYPE = parttype; if (purchasec != string.Empty) ppn.SUPPLYCIRCLE = int.Parse(purchasec); else ppn.SUPPLYCIRCLE = 10; #region �ж�Unit�Ƿ��Ǻϸ��ʽ DataRow[] pone = unitds.Tables[0].Select("name ='" + partunit + "'"); if (pone.Length != 0) { ppn.PART_UNIT = partunit; } else { MessageBox.Show("��λ���Ʋ��淶,���飡","������ʾ"); tb_unit.Focus(); return; } #endregion int count = ppn.Add(); if (count == 0) { MessageBox.Show("���ʧ��"); return; } MessageBox.Show("��������ɹ�!! ", "��ܰ��ʾ!"); QuerydataBind(); #region //int cou = PartParameter.GetSpecCou(activity); //DataGridViewRow newrow = new DataGridViewRow(); //dgv1.Rows.Insert(0, newrow); //newrow.CreateCells(dgv1); //newrow.Cells[11 + cou].Value = site; //if (cou > 0) //{ // newrow.Cells[4].Value = spec1; //} //if (cou > 1) //{ // newrow.Cells[5].Value = spec2; //} //if (cou > 2) //{ // newrow.Cells[6].Value = spec3; //} //if (cou > 3) //{ // newrow.Cells[7].Value = spec4; //} //newrow.Cells[2].Value = parttype; //newrow.Cells[3].Value = partspec; //newrow.Cells[4+cou].Value = partmat; //newrow.Cells[5 + cou].Value = partcert; //newrow.Cells[6 + cou].Value = partunit; ////newrow.Cells["�ܶȵ�λ"].Value = partunit; //newrow.Cells[9 + cou].Value = partlevel; //newrow.Cells[7 + cou].Value = partunitdestiny; //newrow.Cells[10 + cou].Value = activity; //dgv1.Rows.Add(newrow); #endregion } catch (Exception err) { MessageBox.Show("����ԭ��" + err.Message, "������ʾ��Ϣ", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
private void btn_save_Click(object sender, EventArgs e) { //string projectid = cmb_project.SelectedValue.ToString(); if (ProjectId == string.Empty) { MessageBox.Show("��ѡ����Ŀ��"); return; } if (dgv1.RowCount == 0) { MessageBox.Show("��ѡ�����ݣ�"); return; } string site = cmb_site.SelectedValue.ToString(); int kqrow; kqrow = dgv1.RowCount - 1; try { DataSet unitds=PartParameter.QueryPartPara("select name from mm_unit_tab"); #region ѭ����,�������� for (int i = 0; i <= kqrow; i++) { string partno = dgv1.Rows[i].Cells["�����"].Value.ToString().Trim(); int partid =int.Parse( dgv1.Rows[i].Cells["���"].Value.ToString()); if (Part.Exist(partno, partid)) { MessageBox.Show("��"+partid.ToString()+"�б����ظ������飡"); return; } Part ppn = new Part(); string partspec = dgv1.Rows[i].Cells["������"].Value.ToString().Trim(); string parttype = dgv1.Rows[i].Cells["������"].Value.ToString().Trim(); string partmat = dgv1.Rows[i].Cells["����"].Value.ToString().Trim(); string partlevel = dgv1.Rows[i].Cells["�ȼ�"].Value.ToString().Trim(); string partcert = dgv1.Rows[i].Cells["֤��"].Value.ToString().Trim(); string partpurchase = dgv1.Rows[i].Cells["�ɹ�����"].Value.ToString().Trim(); string destinyunit = dgv1.Rows[i].Cells["�ܶȵ�λ"].Value.ToString().Trim(); string replacecode = dgv1.Rows[i].Cells["�����"].Value.ToString().Trim(); string spec1="",spec2="",spec3="",spec4=""; if(lspec1.Visible==true) spec1 = dgv1.Rows[i].Cells[lspec1.Text].Value.ToString().Trim(); if (lspec2.Visible == true) spec2 = dgv1.Rows[i].Cells[lspec2.Text].Value.ToString().Trim(); if (lspec3.Visible == true) spec3 = dgv1.Rows[i].Cells[lspec3.Text].Value.ToString().Trim(); if (lspec4.Visible == true) spec4 = dgv1.Rows[i].Cells[lspec4.Text].Value.ToString().Trim(); string partunit = dgv1.Rows[i].Cells["��λ"].Value.ToString().Trim(); string partunitdestiny = dgv1.Rows[i].Cells["��λ�ܶ�"].Value.ToString().Trim(); ppn.PART_NO = partno; ppn.CONTRACT = site; ppn.PARENTID = int.Parse(activity); ppn.PART_CERT = partcert; decimal temaa = decimal.Parse(partunitdestiny); //temaa = decimal.Round(decimal.Parse("0.3333333"), 2); ppn.PART_UNITDENSITY = decimal.Round(temaa, 2); ppn.PART_LEVEL = partlevel; ppn.PART_SPEC = partspec; ppn.PART_SPEC1 = spec1; ppn.PART_SPEC2 = spec2; ppn.PART_SPEC3 = spec3; ppn.PART_SPEC4 = spec4; ppn.PART_DENSITYUNIT = destinyunit; ppn.PART_UNIT = partunit; ppn.PART_MAT = partmat; ppn.PART_TYPE = parttype; ppn.UPDATEDATE = DateTime.Today; ppn.UPDATER = LoginUser; ppn.REPLACE_CODE = replacecode; if (partpurchase != string.Empty) ppn.SUPPLYCIRCLE = int.Parse(partpurchase); else ppn.SUPPLYCIRCLE = 10; ppn.ID =int.Parse( dgv1.Rows[i].Cells["���"].Value.ToString()); #region �ж�Unit�Ƿ��Ǻϸ��ʽ if (dgv1.Rows[i].Cells["��λ"].Value != null && dgv1.Rows[i].Cells["��λ"].Value.ToString()!=string.Empty) { string punit = dgv1.Rows[i].Cells["��λ"].Value.ToString().Trim().ToLower(); DataRow[] pone = unitds.Tables[0].Select("name ='" + punit + "'"); if (pone.Length != 0) { ppn.PART_UNIT = punit; } else { MessageBox.Show("��" + (i + 1) + "�е�λ���Ʋ��淶,���飡", "������ʾ"); dgv1.Rows[i].Selected = true; return; } } #endregion int count = ppn.Update(); if (count == 0) { MessageBox.Show("��"+partid.ToString()+"�и���ʧ��"); } } #endregion MessageBox.Show("����ɹ�!! ", "��ܰ��ʾ!"); } catch (Exception err) { MessageBox.Show("����ԭ��" + err.Message, "������ʾ��Ϣ", MessageBoxButtons.OK, MessageBoxIcon.Information); } QuerydataBind(); }