Esempio n. 1
0
        public static string getservertime()
        {
            string sql  = "select getdate() as SysDate";
            string name = SQLHELP.ExecuteScalar(sql, CommandType.Text).ToString();

            return(name);
        }
Esempio n. 2
0
        private void button1_Click(object sender, EventArgs e)
        {
            string 发货数量 = textBox1.Text;
            string 发货时间 = dateEdit1.Text;



            if (发货数量 == "")
            {
                MessageBox.Show("发货数量不能为空");
                return;
            }
            if (发货时间 == "")
            {
                MessageBox.Show("发货时间不能为空");
                return;
            }
            string sql = "insert into tb_fahuojilu(定位,部门,发货数量,发货时间,类别) values('" + id + "','仓库','" + 发货数量 + "','" + 发货时间 + "','到货')";

            SQLHELP.ExecuteScalar(sql, CommandType.Text);
            this.Close();
        }
Esempio n. 3
0
        private void simpleButton4_Click(object sender, EventArgs e)
        {
            if (comdanwei.Text.Trim() == "")
            {
                MessageBox.Show("必须选择单位!");
                return;
            }
            if (comboBoxEdit1.Text.Trim() == "")
            {
                MessageBox.Show("必须选择一级名称!");
                return;
            }
            if (comboBoxEdit2.Text.Trim() == "")
            {
                MessageBox.Show("必须选择二级名称!");
                return;
            }
            if (comboBoxEdit3.Text.Trim() == "")
            {
                MessageBox.Show("必须选择三级名称!");
                return;
            }
            if (txtyulan.Text == "")
            {
                MessageBox.Show("预览为空,请先预览再生成!");
                return;
            }

            string sql111 = "select * from tb_erpfirst where 一级='" + comboBoxEdit1.Text + "'";
            string yiji1  = Convert.ToString(SQLHELP.ExecuteScalar(sql111, CommandType.Text));

            if (yiji1 == "")
            {
                MessageBox.Show("一级名称不存在,请重新输入!");
                return;
            }
            string sql222 = "select * from tb_erpsecond where 二级='" + comboBoxEdit2.Text + "'";
            string erji2  = Convert.ToString(SQLHELP.ExecuteScalar(sql222, CommandType.Text));

            if (erji2 == "")
            {
                MessageBox.Show("二级名称不存在,请重新输入!");
                return;
            }
            string sql333 = "select * from tb_erpthird where 三级='" + comboBoxEdit3.Text + "'";
            string sanji3 = Convert.ToString(SQLHELP.ExecuteScalar(sql333, CommandType.Text));

            if (sanji3 == "")
            {
                MessageBox.Show("三级名称不存在,请重新输入!");
                return;
            }
            string    sql1122 = "select * from tb_xinerp where 三级='" + comboBoxEdit3.Text + "' and 四级='" + txtyulan.Text.Trim() + "'";
            DataTable dtttt   = SQLHELP.GetDataTable(sql1122, CommandType.Text);

            if (dtttt.Rows.Count > 0)
            {
                MessageBox.Show("该ERP已存在!");
                gridControl4.DataSource = SQLHELP.GetDataTable(sql1122, CommandType.Text);
                return;
            }

            if (MessageBox.Show("确认生号吗?", "软件提示", MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation) == DialogResult.Yes)
            {
                string sql12345 = "insert into tb_xinerp (一级,二级,三级,四级,单位,生成时间,生成人) VALUES ('" + comboBoxEdit1.Text.Trim() + "','" + comboBoxEdit2.Text.Trim() + "','" + comboBoxEdit3.Text.Trim() + "','" + txtyulan.Text.Trim() + "','" + comdanwei.Text.Trim() + "','" + DateTime.Now + "','" + yonghu + "')";
                SQLHELP.ExecuteScalar(sql12345, CommandType.Text);
                string    sql11 = "select * from tb_xinerp where 新编号 is  null ";
                DataTable dt    = SQLHELP.GetDataTable(sql11, CommandType.Text);
                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    string id    = dt.Rows[i]["id"].ToString();
                    string yiji  = dt.Rows[i]["一级"].ToString();
                    string sql12 = " Select 编号 from tb_erpfirst where 一级='" + yiji.Trim() + "' ";
                    string id1   = SQLHELP.ExecuteScalar(sql12, CommandType.Text).ToString();
                    string yiji2 = dt.Rows[i]["二级"].ToString();
                    string sql2  = " Select id from tb_erpsecond where  二级='" + yiji2.Trim() + "' ";
                    string id2   = SQLHELP.ExecuteScalar(sql2, CommandType.Text).ToString();

                    if (id2.Length == 1)
                    {
                        id2 = "00" + id2;
                    }
                    if (id2.Length == 2)
                    {
                        id2 = "0" + id2;
                    }
                    string yiji3 = dt.Rows[i]["三级"].ToString();
                    string sql3  = " Select id from tb_erpthird where  三级='" + yiji3.Trim() + "' ";
                    string id3   = SQLHELP.ExecuteScalar(sql3, CommandType.Text).ToString();

                    if (id3.Length == 1)
                    {
                        id3 = "00000" + id3;
                    }
                    if (id3.Length == 2)
                    {
                        id3 = "0000" + id3;
                    }
                    if (id3.Length == 3)
                    {
                        id3 = "000" + id3;
                    }
                    if (id3.Length == 4)
                    {
                        id3 = "00" + id3;
                    }
                    if (id3.Length == 5)
                    {
                        id3 = "0" + id3;
                    }

                    string id4 = dt.Rows[i]["id"].ToString();

                    if (id4.Length == 1)
                    {
                        id4 = "00000" + id4;
                    }
                    if (id4.Length == 2)
                    {
                        id4 = "0000" + id4;
                    }
                    if (id4.Length == 3)
                    {
                        id4 = "000" + id4;
                    }
                    if (id4.Length == 4)
                    {
                        id4 = "00" + id4;
                    }
                    if (id4.Length == 5)
                    {
                        id4 = "0" + id4;
                    }
                    string yiji4 = id1 + id2 + id3 + id4;

                    string sql123456 = "update tb_xinerp set 新编号='" + yiji4 + "' where id='" + id + "'";
                    SQLHELP.ExecuteScalar(sql123456, CommandType.Text);
                    MessageBox.Show("生成成功!");

                    string sql112233 = " select * from tb_xinerp    where  新编号 ='" + yiji4 + "' ";
                    gridControl4.DataSource           = SQLHELP.GetDataTable(sql112233, CommandType.Text);
                    gridView4.Columns["id"].Visible   = false;
                    gridView4.Columns["生成人"].Visible  = false;
                    gridView4.Columns["生成时间"].Visible = false;
                }
            }
        }