private void simpleButton1_Click(object sender, EventArgs e) { string sql = "select * from tb_caigoutaizhang where id='" + id + "'"; DataTable dtt = SQLhelp1.GetDataTable(sql, CommandType.Text); string fapiaohao = dtt.Rows[0]["发票编号"].ToString(); string fapiaohao1 = fapiaohao + txtfapiaohao.Text + ";"; string fapiaojine = dtt.Rows[0]["发票金额"].ToString(); string fapiaojine1 = dtt.Rows[0]["发票金额"].ToString() + txtjine.Text + ";"; string fapiaoriqi = dtt.Rows[0]["发票开具日期"].ToString(); string fapiaoriqi1 = dtt.Rows[0]["发票开具日期"].ToString() + txtkaipiao.Text + ";"; string dangqianriqi = dtt.Rows[0]["发票收到日期"].ToString(); string dangqianriqi1 = dtt.Rows[0]["发票收到日期"].ToString() + DateTime.Now.ToString("yyyyMMdd") + ";"; double hetongzongjia = Convert.ToDouble(dtt.Rows[0]["合同总价"]); string[] sArray = fapiaojine1.Split(new char[1] { ';' }); double zongjia1 = 0; double zongjia = 0; for (int i = 0; i < sArray.Length; i++) { if (sArray[i] != "") { zongjia += Convert.ToDouble(sArray[i]); double c = Convert.ToDouble(sArray[i]); zongjia1 += c; string kn = (zongjia1).ToString("N2"); zongjia = Convert.ToDouble(kn); } } if (hetongzongjia == zongjia) { string sql3 = "update tb_caigoutaizhang set 发票状态='全到' where id='" + id + "' "; SQLhelp1.ExecuteScalar(sql3, CommandType.Text); } if (hetongzongjia > zongjia) { string sql3 = "update tb_caigoutaizhang set 发票状态='已到部分' where id='" + id + "' "; SQLhelp1.ExecuteScalar(sql3, CommandType.Text); } if (hetongzongjia < zongjia) { MessageBox.Show("发票金额大于合同金额!"); return; } string sql2 = "update tb_caigoutaizhang set 发票编号='" + fapiaohao1 + "' ,发票金额='" + fapiaojine1 + "' ,发票开具日期='" + fapiaoriqi1 + "',发票收到日期='" + dangqianriqi1 + "' where id='" + id + "' "; SQLhelp1.ExecuteScalar(sql2, CommandType.Text); string sql1111 = "insert into tb_fapiaodengjibiao (收到发票日期,供方名称,发票编号,发票日期,发票金额,合同号,采购员,提交人,备注) values('" + DateTime.Now.ToString("yyyyMMdd") + "' ,'" + gongfangmingcheng + "' ,'" + txtfapiaohao.Text + "' ,'" + txtkaipiao.Text + "' ,'" + txtjine.Text + "' ,'" + txthetonghao.Text + "' ,'" + caigouyuan + "','" + yonghu + "','" + txtbeizhu.Text + "')"; SQLhelp1.ExecuteScalar(sql1111, CommandType.Text); MessageBox.Show("提交成功!"); this.DialogResult = DialogResult.OK; this.Close(); }
private double chaxundanzhong(string a, string b) { string sql = "select 密度单重 from db_cailiaoguige where 材料='" + a + "' and 规格='" + b + "'"; string ret = Convert.ToString(SQLhelp1.ExecuteScalar(sql, CommandType.Text)); if (ret != "") { midu = Math.Round(Convert.ToDouble(ret), 3); } else { midu = Convert.ToDouble(0); } return(midu); }
private void 撤回ToolStripMenuItem_Click(object sender, EventArgs e) { int[] a = gridView4.GetSelectedRows(); foreach (int i in a) { string shenhe = gridView4.GetRowCellValue(i, "审核确认").ToString(); if (shenhe == "1") { MessageBox.Show("已经确认,无法删除!"); return; } } foreach (int i in a) { string id = gridView4.GetRowCellValue(i, "id").ToString(); string hetonghao = gridView4.GetRowCellValue(i, "合同号").ToString(); string fapiaohao = gridView4.GetRowCellValue(i, "发票编号").ToString() + ";"; string fapiaoriqi = gridView4.GetRowCellValue(i, "发票日期").ToString() + ";"; string fapiaojine = gridView4.GetRowCellValue(i, "发票金额").ToString() + ";"; string kaijvriqi = gridView4.GetRowCellValue(i, "收到发票日期").ToString() + ";"; string sql = "select * from tb_caigoutaizhang where 合同号='" + hetonghao + "'"; DataTable dt = SQLhelp1.GetDataTable(sql, CommandType.Text); string fapiaobianhao = dt.Rows[0]["发票编号"].ToString(); string zuizhongfapiaohao = fapiaobianhao.Replace(fapiaohao, ""); string fapiaoriqi1 = dt.Rows[0]["发票开具日期"].ToString(); string zuifapiaoriqi1 = fapiaoriqi1.Replace(fapiaoriqi, ""); string fapiaojine11 = dt.Rows[0]["发票金额"].ToString(); string zuizhongfapiaojine = fapiaojine11.Replace(fapiaojine, ""); string kaijvriqi11 = dt.Rows[0]["发票收到日期"].ToString(); string zuizhongkaijvriqi = kaijvriqi11.Replace(kaijvriqi, ""); string sql1 = "update tb_caigoutaizhang set 发票编号='" + zuizhongfapiaohao + "',发票收到日期='" + zuizhongkaijvriqi + "',发票金额='" + zuizhongfapiaojine + "',发票开具日期='" + zuifapiaoriqi1 + "',发票状态=NULL where 合同号='" + hetonghao + "'"; SQLhelp1.ExecuteScalar(sql1, CommandType.Text); string sql12 = "delete from tb_fapiaodengjibiao where id='" + id + "'"; SQLhelp1.ExecuteScalar(sql12, CommandType.Text); } MessageBox.Show("撤回成功!"); Reload(); this.DialogResult = DialogResult.OK; }
private void comboBox5_Click(object sender, EventArgs e) { comboBox5.Items.Clear(); string sql = "select 规格 from db_cailiaoguige where 材料='" + comboBox1.Text.Trim() + "' "; string ret = Convert.ToString(SQLhelp1.ExecuteScalar(sql, CommandType.Text)); if (ret != "") { DataTable dt = SQLhelp1.GetDataTable(sql, CommandType.Text); foreach (DataRow row in dt.Rows) { string a = row["规格"].ToString(); if (comboBox5.Items.Cast <object>().All(x => x.ToString() != a)) { comboBox5.Items.Add(a); } } } }
private void 保存ToolStripMenuItem_Click(object sender, EventArgs e) { int[] a = gridView4.GetSelectedRows(); foreach (int i in a) { string id = Convert.ToString(gridView4.GetRowCellValue(i, "id")); string zhuangtai1 = Convert.ToString(gridView4.GetRowCellValue(i, "申请付款进度1")); string zhuangtai2 = Convert.ToString(gridView4.GetRowCellValue(i, "申请付款进度2")); string zhuangtai3 = Convert.ToString(gridView4.GetRowCellValue(i, "申请付款进度3")); string zhuangtai4 = Convert.ToString(gridView4.GetRowCellValue(i, "申请付款进度4")); string jine1 = Convert.ToString(gridView4.GetRowCellValue(i, "申请付款金额1")); string jine2 = Convert.ToString(gridView4.GetRowCellValue(i, "申请付款金额2")); string jine3 = Convert.ToString(gridView4.GetRowCellValue(i, "申请付款金额3")); string jine4 = Convert.ToString(gridView4.GetRowCellValue(i, "申请付款金额4")); string fukuanfangshi = Convert.ToString(gridView4.GetRowCellValue(i, "付款方式")); string fapiaozhuangtai = Convert.ToString(gridView4.GetRowCellValue(i, "发票状态")); string zhibaoqi = Convert.ToString(gridView4.GetRowCellValue(i, "质保期")); string zhibaojin = Convert.ToString(gridView4.GetRowCellValue(i, "质保金")); string tijiaoshijian = DateTime.Now.ToString(); string sql11 = "update tb_caigoutaizhang set 付款方式='" + fukuanfangshi + "' ,质保期='" + zhibaoqi + "',质保金='" + zhibaojin + "' ,合同登记时间='" + tijiaoshijian + "' where id='" + id + "' "; SQLhelp1.ExecuteScalar(sql11, CommandType.Text); if (zhuangtai1 == "") { if (jine1 != "") { string sql = "update tb_caigoutaizhang set 申请付款金额1='" + jine1 + "' where id='" + id + "' "; SQLhelp1.ExecuteScalar(sql, CommandType.Text); } } if (zhuangtai1 != "" && zhuangtai2 == "") { if (jine2 != "") { string sql = "update tb_caigoutaizhang set 申请付款金额2='" + jine2 + "' where id='" + id + "' "; SQLhelp1.ExecuteScalar(sql, CommandType.Text); } } if (zhuangtai2 != "" && zhuangtai3 == "") { if (jine3 != "") { string sql = "update tb_caigoutaizhang set 申请付款金额3='" + jine3 + "' where id='" + id + "' "; SQLhelp1.ExecuteScalar(sql, CommandType.Text); } } if (zhuangtai3 != "" && zhuangtai4 == "") { if (jine4 != "") { string sql = "update tb_caigoutaizhang set 申请付款金额4='" + jine4 + "' where id='" + id + "' "; SQLhelp1.ExecuteScalar(sql, CommandType.Text); } } } MessageBox.Show("已保存!"); Reload(); }
private void 提交审批ToolStripMenuItem_Click(object sender, EventArgs e) { int[] a = gridView4.GetSelectedRows(); foreach (int i in a) { string id = gridView4.GetRowCellValue(i, "id").ToString(); qingdan1 += id + "|"; } if (qingdan1 == "") { MessageBox.Show("没有选中,请选中!"); return; } bool b = false; foreach (int i in a) { string id = Convert.ToString(gridView4.GetRowCellValue(i, "id")); double zongji = Convert.ToDouble(gridView4.GetRowCellValue(i, "合同总价")); string zhuangtai1 = Convert.ToString(gridView4.GetRowCellValue(i, "申请付款进度1")); string zhuangtai2 = Convert.ToString(gridView4.GetRowCellValue(i, "申请付款进度2")); string zhuangtai3 = Convert.ToString(gridView4.GetRowCellValue(i, "申请付款进度3")); string zhuangtai4 = Convert.ToString(gridView4.GetRowCellValue(i, "申请付款进度4")); string jine1 = Convert.ToString(gridView4.GetRowCellValue(i, "申请付款金额1")); string jine2 = Convert.ToString(gridView4.GetRowCellValue(i, "申请付款金额2")); string jine3 = Convert.ToString(gridView4.GetRowCellValue(i, "申请付款金额3")); string jine4 = Convert.ToString(gridView4.GetRowCellValue(i, "申请付款金额4")); if (zhuangtai1 == "") { if (jine1 == "") { MessageBox.Show("请填写申请付款金额1的金额!"); return; } string[] strArray = jine1.Split(new char[1] { ';' }); double jinge11 = 0; double qian = 0; for (int j = 0; j < strArray.Length; j++) { if (strArray[j] != "") { double c = Convert.ToDouble(strArray[j]); qian += c; string kn = (qian).ToString("N2"); jinge11 = Convert.ToDouble(kn); } } if (zongji < jinge11) { MessageBox.Show("付款金额大于合同总价!请重新填写!"); } else { string sql = "update tb_caigoutaizhang set 申请付款金额1='" + jine1 + "',申请付款日期1='" + DateTime.Now + "',申请付款进度1='已提交' where id='" + id + "'"; SQLhelp1.ExecuteScalar(sql, CommandType.Text); b = true; } } if (zhuangtai1 != "" && zhuangtai2 == "") { if (jine2 == "") { MessageBox.Show("请填写申请付款金额2的金额!"); return; } string[] strArray2 = jine2.Split(new char[1] { ';' }); string[] strArray = jine1.Split(new char[1] { ';' }); double jinge11 = 0; double qian = 0; double zongjia1 = 0; double qian2 = 0; for (int j = 0; j < strArray.Length; j++) { if (strArray[j] != "") { double c = Convert.ToDouble(strArray[j]); qian += c; string kn = (qian).ToString("N2"); jinge11 = Convert.ToDouble(kn); } } for (int z = 0; z < strArray2.Length; z++) { if (strArray2[z] != "") { double d = Convert.ToDouble(strArray2[z]); qian2 += d; string kn2 = (jinge11 + qian2).ToString("N2"); zongjia1 = Convert.ToDouble(kn2); } } if (zongji < zongjia1) { MessageBox.Show("付款金额大于合同总价!请重新填写!"); } else { string sql = "update tb_caigoutaizhang set 申请付款金额2='" + jine2 + "',申请付款日期2='" + DateTime.Now + "' ,申请付款进度2='已提交' where id='" + id + "'"; SQLhelp1.ExecuteScalar(sql, CommandType.Text); b = true; } } if (zhuangtai2 != "" && zhuangtai3 == "") { if (jine3 == "") { MessageBox.Show("请填写申请付款金额3的金额!"); return; } string[] strArray3 = jine3.Split(new char[1] { ';' }); string[] strArray2 = jine2.Split(new char[1] { ';' }); string[] strArray = jine1.Split(new char[1] { ';' }); double jinge11 = 0; double qian = 0; double zongjia1 = 0; double qian2 = 0; double zongjia2 = 0; double qian3 = 0; for (int j = 0; j < strArray.Length; j++) { if (strArray[j] != "") { double c = Convert.ToDouble(strArray[j]); qian += c; string kn = (qian).ToString("N2"); jinge11 = Convert.ToDouble(kn); } } for (int z = 0; z < strArray2.Length; z++) { if (strArray2[z] != "") { double d = Convert.ToDouble(strArray2[z]); qian2 += d; string kn2 = (jinge11 + qian2).ToString("N2"); zongjia1 = Convert.ToDouble(kn2); } } for (int j = 0; j < strArray3.Length; j++) { if (strArray3[j] != "") { double c = Convert.ToDouble(strArray3[j]); qian3 += c; string kn = (zongjia1 + qian3).ToString("N2"); zongjia2 = Convert.ToDouble(kn); } } if (zongji < zongjia2) { MessageBox.Show("付款金额大于合同总价!请重新填写!"); } else { string sql = "update tb_caigoutaizhang set 申请付款金额3='" + jine3 + "',申请付款日期3='" + DateTime.Now + "',申请付款进度3='已提交' where id='" + id + "'"; SQLhelp1.ExecuteScalar(sql, CommandType.Text); b = true; } } if (zhuangtai3 != "" && zhuangtai4 == "") { if (jine4 == "") { MessageBox.Show("请填写申请付款金额4的金额!"); return; } string[] strArray4 = jine4.Split(new char[1] { ';' }); string[] strArray3 = jine3.Split(new char[1] { ';' }); string[] strArray2 = jine2.Split(new char[1] { ';' }); string[] strArray = jine1.Split(new char[1] { ';' }); double jinge11 = 0; double qian = 0; double zongjia1 = 0; double qian2 = 0; double zongjia2 = 0; double qian3 = 0; double zongjia3 = 0; double qian4 = 0; for (int j = 0; j < strArray.Length; j++) { if (strArray[j] != "") { double c = Convert.ToDouble(strArray[j]); qian += c; string kn = (qian).ToString("N2"); jinge11 = Convert.ToDouble(kn); } } for (int z = 0; z < strArray2.Length; z++) { if (strArray2[z] != "") { double d = Convert.ToDouble(strArray2[z]); qian2 += d; string kn2 = (jinge11 + qian2).ToString("N2"); zongjia1 = Convert.ToDouble(kn2); } } for (int j = 0; j < strArray3.Length; j++) { if (strArray3[j] != "") { double c = Convert.ToDouble(strArray3[j]); qian3 += c; string kn = (zongjia1 + qian3).ToString("N2"); zongjia2 = Convert.ToDouble(kn); } } for (int j = 0; j < strArray4.Length; j++) { if (strArray4[j] != "") { double c = Convert.ToDouble(strArray4[j]); qian4 += c; string kn = (zongjia2 + qian4).ToString("N2"); zongjia3 = Convert.ToDouble(kn); } } if (zongji < zongjia3) { MessageBox.Show("付款金额大于合同总价!请重新填写!"); } else { string sql = "update tb_caigoutaizhang set 申请付款金额4='" + jine4 + "',申请付款日期4='" + DateTime.Now + "',申请付款进度4='已提交' where id='" + id + "'"; SQLhelp1.ExecuteScalar(sql, CommandType.Text); b = true; } } } if (b) { MessageBox.Show("已提交!"); Reload(); } //foreach (int i in a) //{ // string id = Convert.ToString(gridView4.GetRowCellValue(i, "id")); // string zhuangtai1 = Convert.ToString(gridView4.GetRowCellValue(i, "申请付款进度1")); // string zhuangtai2 = Convert.ToString(gridView4.GetRowCellValue(i, "申请付款进度2")); // string zhuangtai3 = Convert.ToString(gridView4.GetRowCellValue(i, "申请付款进度3")); // string zhuangtai4 = Convert.ToString(gridView4.GetRowCellValue(i, "申请付款进度4")); // string jine1 = Convert.ToString(gridView4.GetRowCellValue(i, "申请付款金额1")); // string jine2 = Convert.ToString(gridView4.GetRowCellValue(i, "申请付款金额2")); // string jine3 = Convert.ToString(gridView4.GetRowCellValue(i, "申请付款金额3")); // string jine4 = Convert.ToString(gridView4.GetRowCellValue(i, "申请付款金额4")); // if (zhuangtai1 == "") // { // string sql = "update tb_caigoutaizhang set 申请付款金额1='" + jine1 + "',申请付款日期1='" + DateTime.Now + "',申请付款进度1='已提交' where id='" + id + "'"; // SQLhelp1.ExecuteScalar(sql, CommandType.Text); // } // if (zhuangtai1 != "" && zhuangtai2 == "") // { // string sql = "update tb_caigoutaizhang set 申请付款金额2='" + jine2 + "',申请付款日期2='" + DateTime.Now + "' ,申请付款进度2='已提交' where id='" + id + "'"; // SQLhelp1.ExecuteScalar(sql, CommandType.Text); // } // if (zhuangtai2 != "" && zhuangtai3 == "") // { // string sql = "update tb_caigoutaizhang set 申请付款金额3='" + jine3 + "',申请付款日期3='" + DateTime.Now + "',申请付款进度3='已提交' where id='" + id + "'"; // SQLhelp1.ExecuteScalar(sql, CommandType.Text); // } // if (zhuangtai3 != "" && zhuangtai4 == "") // { // string sql = "update tb_caigoutaizhang set 申请付款金额4='" + jine4 + "',申请付款日期4='" + DateTime.Now + "',申请付款进度4='已提交' where id='" + id + "'"; // SQLhelp1.ExecuteScalar(sql, CommandType.Text); // } //} //MessageBox.Show("已提交!"); //Reload(); }