public static void Save() { ConnDB conn = new ConnDB(); string sql; bool isok = false; string yyyymm = DirectLabourPriceQuery.GetMonth(); if (yyyymm != "") { dlpuform.gridView1.FocusInvalidRow(); for (int i = 0; i < dlpuform.gridView1.RowCount; i++) { sql = "update cost_direct_labour_price set price = " + dlpuform.gridView1.GetDataRow(i).ItemArray[3].ToString() + " where yyyymm = '" + yyyymm + "' and work_type = " + dlpuform.gridView1.GetDataRow(i).ItemArray[1].ToString(); isok = conn.EditDatabase(sql); } } if (isok) { MessageBox.Show("修改成功!"); DirectLabourPriceQuery.RefreshEX(); dlpuform.Close(); } else { MessageBox.Show("失败!"); } dlpuform.ischange = false; conn.Close(); dlpuform.Close(); DirectLabourPrice.savetype = "insert"; }
public static void Save() { if (dlpiform == null || dlpiform.IsDisposed) { } else { ConnDB conn = new ConnDB(); string strsql; bool isok = false; DateTime dt1 = Convert.ToDateTime(dlpiform.dateTimePicker1.Text); DateTime dt2 = System.DateTime.Now; int month = (dt2.Year - dt1.Year) * 12 + (dt2.Month - dt1.Month); if (!dlpiform.Exist()) { if (month < -1) { MessageBox.Show("月份错误!"); } else { dlpiform.gridView1.FocusInvalidRow(); for (int i = 0; i < dlpiform.gridView1.RowCount; i++) { strsql = "insert into cost_direct_labour_price(yyyymm,work_type,price) values('" + dlpiform.dateTimePicker1.Text.ToString() + "'," + dlpiform.gridView1.GetDataRow(i).ItemArray[0].ToString() + "," + Common.IsNull(dlpiform.gridView1.GetDataRow(i).ItemArray[2].ToString()) + ")"; isok = conn.EditDatabase(strsql); } if (isok) { MessageBox.Show("保存成功!"); DirectLabourPriceQuery.RefreshEX(); } else { MessageBox.Show("失败!"); } } } dlpiform.ischange = false; conn.Close(); } }
private void simpleButton复制_Click(object sender, EventArgs e) { MessageBoxButtons messButton = MessageBoxButtons.OKCancel; DialogResult dr = MessageBox.Show("将按最近的月度数据自动新增当前选择月份的数据,确认复制吗?", "复制最近月份数据", messButton); if (dr == DialogResult.OK) { ConnDB conn = new ConnDB(); string strsql; bool isok = false; DateTime dt1 = Convert.ToDateTime(dlpiform.dateTimePicker1.Text); DateTime dt2 = System.DateTime.Now; int month = (dt2.Year - dt1.Year) * 12 + (dt2.Month - dt1.Month); if (!dlpiform.Exist()) { if (month < -1) { MessageBox.Show("月份错误!"); } else { strsql = "insert into cost_direct_labour_price(yyyymm,work_type,price) select '" + dlpiform.dateTimePicker1.Text + "',work_type,price from cost_direct_labour_price where YYYYMM = (select Max(yyyymm) from cost_direct_labour_price) "; isok = conn.EditDatabase(strsql); if (isok) { MessageBox.Show("复制成功!"); DirectLabourPriceQuery.RefreshEX(); this.Close(); } } } conn.Close(); } //Exist(); //ShowDetail(); }
private void barButtonItem刷新_ItemClick(object sender, ItemClickEventArgs e) { DirectLabourPriceQuery.RefreshEX(); }