Exemplo n.º 1
0
        public void freshen()
        {
            string sql = "select * from Storage order by S_ID";

            dtInfo = DBHLper.GetTable(sql);
            dataGridView1.DataSource = dtInfo;
            InitDataSet();
            this.label3.Text = "第" + pageCurrent + "页" + "共" + pageCount + "页" + "共" + nMax + "条";
            dataGridView1.AllowUserToAddRows = false;
        }
Exemplo n.º 2
0
        //修改
        //private void button2_Click(object sender, EventArgs e)
        //{
        //    string PhysicalPath = this.textBox1.Text;
        //    string StorageName = this.textBox2.Text;
        //    string sqlstr = string.Format("update Storage set PhysicalPath='{0}' " +
        //        ",StorageName='{1}' where S_ID={2}", PhysicalPath, StorageName,dgid);
        //    int num= DBHLper.GetExecuteNonQuery(sqlstr);
        //    if (num>0)
        //    {
        //        MessageBox.Show("修改成功!");
        //    }
        //    textBox1.Text = string.Empty;
        //    textBox2.Text = string.Empty;
        //    freshen();
        //}
        //查询
        private void bn_c_Click(object sender, EventArgs e)
        {
            string url    = this.tb_url.Text;
            string strsql = string.Format("select * from Storage where PhysicalPath like '%{0}%' order by S_ID", url);

            dtInfo = DBHLper.GetTable(strsql);
            //dtInfo.Compute("PhysicalPath", url);
            dataGridView1.DataSource = dtInfo;
            InitDataSet();
            this.label3.Text = "第" + pageCurrent + "页" + "共" + pageCount + "页" + "共" + nMax + "条";
            dataGridView1.AllowUserToAddRows = false;
        }
Exemplo n.º 3
0
        //添加
        private void button1_Click(object sender, EventArgs e)
        {
            string PhysicalPath = this.textBox1.Text;
            string StorageName  = this.textBox2.Text;
            int    numsum;

            if (tb_num.Text == string.Empty || tb_num == null)
            {
                numsum = 0;
            }
            else
            {
                numsum = Convert.ToInt32(tb_num.Text);
            }

            if (PhysicalPath == string.Empty || PhysicalPath == "")
            {
                MessageBox.Show("物理路径不能为空!");
                return;
            }
            if (this.button1.Text == "添加")
            {
                string sqlstr = string.Format("insert into Storage(PhysicalPath,DeviceID,Num)" +
                                              "values('{0}','{1}',{2})", PhysicalPath, StorageName, numsum);
                int num = DBHLper.GetExecuteNonQuery(sqlstr);
                if (num > 0)
                {
                    MessageBox.Show("添加成功!");
                }
                else
                {
                    MessageBox.Show("不能添加相同的数据!");
                }
            }
            //修改
            else
            {
                string sqlstr = string.Format("update Storage set PhysicalPath='{0}' " +
                                              ",DeviceID='{1}',num={2} where S_ID={3}", PhysicalPath, StorageName, numsum, dgid);
                int num = DBHLper.GetExecuteNonQuery(sqlstr);
                if (num > 0)
                {
                    MessageBox.Show("修改成功!");
                    this.button1.Text = "添加";
                }
            }
            textBox1.Text = string.Empty;
            textBox2.Text = string.Empty;
            tb_num.Text   = string.Empty;
            freshen();
        }
Exemplo n.º 4
0
        private void ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            //dgid = Convert.ToInt32(dataGridView1.Rows[Countid].Cells["S_ID"].Value.ToString());

            foreach (DataGridViewRow item in dataGridView1.SelectedRows)
            {
                ids += dataGridView1.Rows[item.Index].Cells["S_ID"].Value.ToString() + ",";
            }

            string[] idlist = ids.Split(',');

            //if (dgid <= 0)
            //{
            //    MessageBox.Show("未选中任何行!");
            //    return;
            //}
            int num = 0;

            if (MessageBox.Show("是否删除?", "提示!", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
            {
                try
                {
                    foreach (var item in idlist)
                    {
                        string sqlstr = string.Format("Delete From Storage where S_ID ={0}", item);
                        num = DBHLper.GetExecuteNonQuery(sqlstr);
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.ToString());
                }

                MessageBox.Show("删除成功!");
                freshen();
            }
            else
            {
                return;
                //MessageBox.Show("n");
            }
        }