Example #1
0
        private void saveOnline()
        {
            try
            {
                DataTable changeDt = dt.GetChanges();

                foreach (DataRow dr in changeDt.Rows)
                {
                    string strSave = @"UPDATE [dbo].[flow]
                                    SET [flo_online]='" + dr["flo_online"].ToString() + @"'
                                    ,[flo_finish]='" + dr["flo_finish"].ToString() + @"'
                        WHERE flo_num = '" + dr["flo_num"].ToString() + "'";
                    SQLHelper2.Update(strSave);
                }
            }
            catch
            {
                MessageBox.Show("保存失败!");
            }
            finally
            {
                MessageBox.Show("保存成功!");
                reLoading();
                dataGridView1.DataSource = dt;
                label1.Visible           = false;
            }
        }
Example #2
0
        private void toolStripButton5_Click(object sender, EventArgs e)
        {
            int ind = dataGridView1.CurrentRow.Index;

            if (MessageBox.Show("请确认是否删除?", "删除提示", MessageBoxButtons.YesNo) == DialogResult.Yes)
            {
                string strChange = @"DELETE FROM [dbo].[PDnotes]
                                     WHERE PDtime = '" + dataGridView1[1, ind].Value.ToString() + "'";
                SQLHelper2.Update(strChange);
                MessageBox.Show("删除完成");
                LoadTable();
            }
        }
Example #3
0
        /// <summary>
        /// 新增
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void button1_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)
            {
                string strChd = "F";
                if (checkBox1.Checked == true)
                {
                    strChd = "T";
                }
                else
                {
                    strChd = "F";
                }
                string strSqlPD = @"INSERT INTO [dbo].[PDnotes]
                                               ([PDtime]
                                               ,[PDnum]
                                               ,[PDcoding]
                                               ,[PDname]
                                               ,[PDlever]
                                               ,[PDclassify]
                                               ,[PDdescribe]
                                               ,[PDresult]
                                               ,[PDover]
                                               ,[PDresultDes])
                                         VALUES
                                               ('" + DateTime.Now.ToString("yyyyMMddHHmmss") + @"'
                                               ,'" + 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() + @"')";
                SQLHelper2.Update(strSqlPD);
                MessageBox.Show("新增完成");
                LoadTable();
            }
            else
            {
                MessageBox.Show("无权限");
            }
        }
Example #4
0
        /// <summary>
        /// 删除
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void button3_Click(object sender, EventArgs e)
        {
            if (MessageBox.Show("请确认是否删除?", "删除提示", MessageBoxButtons.YesNo) == DialogResult.Yes)
            {
                string strChange = @"DELETE FROM [dbo].[PDnotes]
                                     WHERE PDtime = '" + textBox7.Text.Trim() + "'";
                SQLHelper2.Update(strChange);
                MessageBox.Show("删除完成");
                LoadTable();
            }
            //    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)
            //{

            //}
            //else
            //{
            //    MessageBox.Show("无权限");
            //}
        }
Example #5
0
        /// <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
            {
            }
        }