private void reLoading() { //string strSqlRead = "SELECT [flo_line] FROM flow WHERE flo_num ='"++"' "; for (int i = 0; i < dt.Rows.Count; i++) { dt.Rows[i]["flo_line"] = SQLHelper2.GetSingleResult("SELECT [flo_line] FROM flow WHERE flo_num ='" + dt.Rows[i]["flo_num"].ToString() + "'"); //拉线 dt.Rows[i]["flo_back"] = SQLHelper2.GetSingleResult("SELECT [flo_back] FROM flow WHERE flo_num ='" + dt.Rows[i]["flo_num"].ToString() + "'"); //返回料 dt.Rows[i]["flo_finish"] = SQLHelper2.GetSingleResult("SELECT [flo_finish] FROM flow WHERE flo_num ='" + dt.Rows[i]["flo_num"].ToString() + "'"); //订单完成 dt.Rows[i]["flo_online"] = SQLHelper2.GetSingleResult("SELECT [flo_online] FROM flow WHERE flo_num ='" + dt.Rows[i]["flo_num"].ToString() + "'"); //上线时间 } }
/// <summary> /// 保存 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void toolStripButton2_Click(object sender, EventArgs e) { //string loginPath = Path.Combine(System.Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments), "user.ini"); //INIHelper.CheckPath(loginPath); //string loginName = INIHelper.Read("LoginName", "1", "001", loginPath); //if (true) //{ // dataGridView1.CommitEdit((DataGridViewDataErrorContexts)123); // dataGridView1.BindingContext[dataGridView1.DataSource].EndCurrentEdit(); // DataTable dtChange = dt.GetChanges(); // foreach (DataRow dr in dtChange.Rows) // { // string strChange = ""; // if (dr.RowState == System.Data.DataRowState.Added) // { // strChange = @"INSERT INTO [dbo].[PDnotes] // ([PDId] // ,[PDtime] // ,[PDnum] // ,[PDcoding] // ,[PDname] // ,[PDlever] // ,[PDclassify] // ,[PDdescribe] // ,[PDresult] // ,[PDover] // ,[PDresultDes]) // VALUES // ('"+dataGridView1.Rows.Count.ToString()+@"' // ,'" + DateTime.Now.ToString("yyyy/MM/dd ") + @"' // ,'" + dr["PDnum"].ToString() + @"' // ,'" + dr["PDcoding"].ToString() + @"' // ,'" + dr["PDname"].ToString() + @"' // ,'" + dr["PDlever"].ToString() + @"' // ,'" + dr["PDclassify"].ToString() + @"' // ,'" + dr["PDdescribe"].ToString() + @"' // ,'" + dr["PDresult"].ToString() + @"' // ,'" + "F" + @"' // ,'" + dr["PDresultDes"].ToString() + @"')"; // } // else if (dr.RowState == System.Data.DataRowState.Deleted) // { // strChange = @"DELETE FROM [dbo].[PDnotes] // WHERE PDtime = '" + dr["PDtime", DataRowVersion.Original].ToString() + @"' // AND PDnum ='" + dr["PDnum", DataRowVersion.Original].ToString() + "'"; // } // else if (dr.RowState == System.Data.DataRowState.Modified) // { // strChange = @"UPDATE [dbo].[PDnotes] // SET [PDnum] = '" + dr["PDnum"].ToString() + @"' // ,[PDcoding] = '" + dr["PDcoding"].ToString() + @"' // ,[PDname] = '" + dr["PDname"].ToString() + @"' // ,[PDlever] = '" + dr["PDlever"].ToString() + @"' // ,[PDclassify] = '" + dr["PDclassify"].ToString() + @"' // ,[PDdescribe] = '" + dr["PDdescribe"].ToString() + @"' // ,[PDresult] = '" + dr["PDresult"].ToString() + @"' // ,[PDover] = '" + dr["PDover"].ToString() + @"' // ,[PDresultDes] = '" + dr["PDresultDes"].ToString() + @"' // WHERE PDId= '" + dr["PDId"].ToString() + "'"; // } // int Rows = SQLHelper2.Update(strChange); // //if (Rows.ToString() != null) // //{ // // MessageBox.Show("提交成功"); // //} // //else // //{ // // MessageBox.Show("提交失败"); // //} // //MessageBox.Show(SQLHelper2.Update(strChange).ToString()); // } // MessageBox.Show("提交成功"); // LoadTable(); //} //else //{ // MessageBox.Show("无权限!"); //} string strChange; if (true) { string strChd; if (checkBox1.Checked == true) { strChd = "T"; } else { strChd = "F"; } string strSearch = @"SELECT COUNT(PDtime) FROM [YouliData].[dbo].[PDnotes] WHERE PDtime ='" + textBox7.Text.Trim() + "'"; if (SQLHelper2.GetSingleResult(strSearch).ToString() != "0") //修改 { strChange = @"UPDATE [dbo].[PDnotes] SET [PDnum] = '" + textBox1.Text.Trim() + @"' ,[PDcoding] = '" + textBox2.Text.Trim() + @"' ,[PDname] = '" + textBox3.Text.Trim() + @"' ,[PDlever] = '" + comboBox1.Text.Trim() + @"' ,[PDclassify] = '" + comboBox2.Text.Trim() + @"' ,[PDdescribe] = '" + textBox4.Text.Trim() + @"' ,[PDresult] = '" + textBox5.Text.Trim() + @"' ,[PDover] = '" + strChd.Trim() + @"' ,[PDresultDes] = '" + textBox6.Text.Trim() + @"' WHERE PDtime= '" + textBox7.Text.Trim() + "'"; } else //新增 { strChange = @"INSERT INTO [dbo].[PDnotes] ([PDtime] ,[PDnum] ,[PDcoding] ,[PDname] ,[PDlever] ,[PDclassify] ,[PDdescribe] ,[PDresult] ,[PDover] ,[PDresultDes]) VALUES ('" + textBox7.Text.Trim() + @"' ,'" + textBox1.Text.Trim() + @"' ,'" + textBox2.Text.Trim() + @"' ,'" + textBox3.Text.Trim() + @"' ,'" + comboBox1.Text.Trim() + @"' ,'" + comboBox2.Text.Trim() + @"' ,'" + textBox4.Text.Trim() + @"' ,'" + textBox5.Text.Trim() + @"' ,'" + strChd.Trim() + @"' ,'" + textBox6.Text.Trim() + @"')"; } try { SQLHelper2.Update(strChange); MessageBox.Show("修改完成"); this.panel1.Size = new System.Drawing.Size(1182, 10); LoadTable(); } catch { MessageBox.Show("修改失败"); } } else { } }