Ejemplo n.º 1
0
        private void showData()
        {
            String    qStr  = "select * from YearPlanning where status = '已下达' or status = '未下达'";
            SQLquery  query = new SQLquery(qStr);
            DataTable dt    = query.doSelect();

            if (dt != null)
            {
                List <string> lcmp  = new List <string>();
                List <string> lyear = new List <string>();
                string        temp;
                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    temp = dt.Rows[i][1].ToString();
                    if (!lcmp.Contains(temp))
                    {
                        lcmp.Add(temp);
                    }
                    temp = dt.Rows[i][2].ToString().Substring(0, 4);
                    if (!lyear.Contains(temp))
                    {
                        lyear.Add(temp);
                    }
                }
                foreach (string s in lcmp)
                {
                    this.cb_company.Items.Add(s);
                }
                foreach (string s in lyear)
                {
                    this.cb_year.Items.Add(s);
                }
            }
        }
        private void btn_transmit_Click(object sender, EventArgs e)
        {
            for (int i = 0; i < this.dataGridView1.Rows.Count; i++)
            {
                if (this.dataGridView1.Rows[i].Cells[0].EditedFormattedValue.ToString() == "True")
                {
                    if (this.dataGridView1.Rows[i].Cells[7].Value.ToString() == "新增" ||
                        this.dataGridView1.Rows[i].Cells[7].Value.ToString() == "不通过")
                    {
                        if (this.usrKind != "业务员")
                        {
                            MessageBox.Show("用户权限不够!", "提示");
                            return;
                        }

                        String   qStr  = "update WeekPlanning set status = '待初审' where ID = '" + this.dataGridView1.Rows[i].Cells["ID"].Value.ToString() + "'";
                        SQLquery query = new SQLquery(qStr);
                        if (query.doModify())
                        {
                            MessageBox.Show("周计划提交成功!", "提示");
                            updateDataGridView();
                        }
                        else
                        {
                            MessageBox.Show("周计划提交失败!", "提示");
                        }
                    }
                    else
                    {
                        MessageBox.Show("该周计划不可提交!", "提示");
                    }
                }
            }
        }
Ejemplo n.º 3
0
        private void  达调度令_Load(object sender, EventArgs e)
        {
            this.dataGridView1.AllowUserToAddRows = false;
            this.xd = false;
            this.cb_jb.Items.Add("Ⅰ级");
            this.cb_jb.Items.Add("Ⅱ级");
            this.cb_jb.Items.Add("Ⅲ级");
            String    qStr  = "select * from " + knd + "Planning where ID = '" + this.id + "'";
            SQLquery  query = new SQLquery(qStr);
            DataTable dt    = query.doSelect();

            if (dt != null)
            {
                this.txt_jsdw.Text = dt.Rows[0][1].ToString();
                string tem = dt.Rows[0][2].ToString();
                this.txt_zxsj.Text = tem.Substring(0, 4) + "-" + tem.Substring(4, 2) + "-" + tem.Substring(6, 2) + " 至 " + tem.Substring(0, 4) + "-" + tem.Substring(8, 2) + "-" + tem.Substring(10, 2);
                this.txt_flsj.Text = DateTime.Now.ToLocalTime().ToString("yyyy-MM-dd hh:mm:ss");
                this.txt_hj.Text   = dt.Rows[0][5].ToString();
                this.txt_bz.Text   = dt.Rows[0][8].ToString();
                this.txt_fj.Text   = dt.Rows[0][9].ToString();
            }

            String    qs2 = "select * from PlanningDetail where planID = '" + this.id + "'";
            SQLquery  q2  = new SQLquery(qs2);
            DataTable dt2 = q2.doSelect();

            if (dt2 != null)
            {
                for (int i = 0; i < dt2.Rows.Count; i++)
                {
                    this.dataGridView1.Rows.Add(dt2.Rows[i][0].ToString(), dt2.Rows[i][1].ToString(), dt2.Rows[i][2].ToString(),
                                                dt2.Rows[i][3].ToString(), dt2.Rows[i][4].ToString(), dt2.Rows[i][5].ToString());
                }
            }
        }
        private void btn_search_Click(object sender, EventArgs e)
        {
            string cmp   = this.cb_company.Text;
            string year  = this.cb_year.Text;
            string ptype = this.cb_type.Text;

            String qStr = "select company,date,amount,type,ID from YearPlanning where company " + (cmp != "" ? ("= '" + cmp + "'") : "is not null") +
                          " and date " + (year != "" ? ("like '" + year + "%'") : "is not null") + " and type " + (ptype != "" ? (" = '" + ptype + "'") : "is not null") +
                          " and status = '已下达'";

            SQLquery  query = new SQLquery(qStr);
            DataTable dt    = query.doSelect();

            if (dt == null)
            {
                MessageBox.Show("未查到符合条件的记录!", "提示");
            }
            else
            {
                this.dataGridView1.Rows.Clear();
                this.dataGridView1.Update();

                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    string tem = dt.Rows[i][1].ToString();
                    string st  = tem.Substring(0, 4) + "-" + tem.Substring(4, 2) + "-" + tem.Substring(6, 2);
                    string et  = tem.Substring(0, 4) + "-" + tem.Substring(8, 2) + "-" + tem.Substring(10, 2);
                    this.dataGridView1.Rows.Add("false", i + 1, dt.Rows[i][0].ToString(), st, et,
                                                dt.Rows[i][2].ToString(), dt.Rows[i][3].ToString(), dt.Rows[i][4].ToString());
                }
            }
        }
Ejemplo n.º 5
0
        private void btn_transmit_Click(object sender, EventArgs e)
        {
            if (this.xd)
            {
                MessageBox.Show("您刚已下达了调度令!", "提示");
                return;
            }

            if (this.txt_zlzt.Text == "" || this.txt_qfr.Text == "" || this.txt_jsrxm.Text == "" || this.cb_jb.Text == "")
            {
                MessageBox.Show("必填项(带*号)不能为空!", "提示");
                return;
            }

            if (!isNum(this.txt_flrczdh.Text) || !isNum(this.txt_jsrczdh.Text))
            {
                MessageBox.Show("传真电话格式错误!", "提示");
                return;
            }

            String    qStr  = "select status from " + knd + "Planning where ID = '" + this.id + "'";
            SQLquery  query = new SQLquery(qStr);
            DataTable dt    = query.doSelect();

            if (dt != null)
            {
                if (dt.Rows[0][0].ToString() != "未下达")
                {
                    MessageBox.Show("该计划调度令已下达!", "提示");
                    return;
                }
            }

            String qStr0 = "insert into TransportSchedule values('" + this.txt_flsj.Text + "','" + this.txt_qfr.Text
                           + "','" + this.txt_zlzt.Text + "','" + this.cb_jb.Text + "','" + this.txt_jsrxm.Text + "','" + this.txt_jsrczdh.Text
                           + "','" + this.txt_flr.Text + "','" + this.txt_flrczdh.Text + "','" + this.id + "')";
            SQLquery query0 = new SQLquery(qStr0);

            if (query0.doModify())
            {
                String   qStr1  = "update " + knd + "Planning set status = '已下达', attachment = '" + this.txt_fj.Text + "' where ID = '" + this.id + "'";
                SQLquery query1 = new SQLquery(qStr1);
                if (query1.doModify())
                {
                    MessageBox.Show("下达调度令成功!", "提示");
                    this.xd = true;
                }
                else
                {
                    MessageBox.Show("下达调度令失败!", "提示");
                }
            }
            else
            {
                MessageBox.Show("下达调度令失败!", "提示");
            }
        }
Ejemplo n.º 6
0
        private void btn_delete_Click(object sender, EventArgs e)
        {
            for (int i = 0; i < this.dataGridView1.Rows.Count; i++)
            {
                if (this.dataGridView1.Rows[i].Cells[0].EditedFormattedValue.ToString() == "True")
                {
                    if (this.dataGridView1.Rows[i].Cells[7].Value.ToString() == "未下达")
                    {
                        //删除年计划
                        deletePlan d = new deletePlan(this.dataGridView1.Rows[i].Cells["ID"].Value.ToString(), "年");
                        bool       b = d.doDelete();

                        //得到对应月计划ID,删除对应月计划
                        String    qStr  = "select ID from MonthPlanning where planID = '" + this.dataGridView1.Rows[i].Cells["ID"].Value.ToString() + "'";
                        SQLquery  query = new SQLquery(qStr);
                        DataTable dt    = query.doSelect();
                        if (dt != null)
                        {
                            for (int j = 0; j < dt.Rows.Count; j++)
                            {
                                //得到对应周计划ID,删除对应周计划
                                String    qStr1  = "select ID from WeekPlanning where planID = '" + dt.Rows[j][0].ToString() + "'";
                                SQLquery  query1 = new SQLquery(qStr1);
                                DataTable dt1    = query1.doSelect();
                                if (dt1 != null)
                                {
                                    for (int k = 0; k < dt1.Rows.Count; k++)
                                    {
                                        deletePlan d1 = new deletePlan(dt1.Rows[k][0].ToString(), "周");
                                        d1.doDelete();
                                    }
                                }

                                deletePlan d2 = new deletePlan(dt.Rows[j][0].ToString(), "月");
                                d2.doDelete();
                            }
                        }

                        if (b)
                        {
                            MessageBox.Show("删除年计划成功!", "提示");
                            this.dataGridView1.Rows.RemoveAt(i);
                            updateDataGridView();
                        }
                        else
                        {
                            MessageBox.Show("删除年计划失败!", "提示");
                        }
                    }
                    else
                    {
                        MessageBox.Show("该年计划不可删除!", "提示");
                    }
                }
            }
        }
        private void 已下达运输周计划列表_Load(object sender, EventArgs e)
        {
            this.dataGridView1.AllowUserToAddRows = false;
            this.cb_type.Items.Add("追加");
            this.cb_type.Items.Add("普通");
            this.cb_type.SelectedIndex = 1;

            for (int i = 1; i < 10; i++)
            {
                this.cb_month.Items.Add("0" + Convert.ToString(i));
            }
            this.cb_month.Items.Add(Convert.ToString(10));
            this.cb_month.Items.Add(Convert.ToString(11));
            this.cb_month.Items.Add(Convert.ToString(12));

            for (int i = 1; i < 5; i++)
            {
                this.cb_zs.Items.Add(i.ToString());
            }

            String    qStr  = "select * from WeekPlanning where status = '已下达'";
            SQLquery  query = new SQLquery(qStr);
            DataTable dt    = query.doSelect();

            if (dt != null)
            {
                List <string> lcmp  = new List <string>();
                List <string> lyear = new List <string>();
                string        temp;
                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    temp = dt.Rows[i][1].ToString();
                    if (!lcmp.Contains(temp))
                    {
                        lcmp.Add(temp);
                    }
                    temp = dt.Rows[i][2].ToString().Substring(0, 4);
                    if (!lyear.Contains(temp))
                    {
                        lyear.Add(temp);
                    }
                }
                foreach (string s in lcmp)
                {
                    this.cb_company.Items.Add(s);
                }
                foreach (string s in lyear)
                {
                    this.cb_year.Items.Add(s);
                }
            }
        }
        private void btn_delete_Click(object sender, EventArgs e)
        {
            for (int i = 0; i < this.dataGridView1.Rows.Count; i++)
            {
                if (this.dataGridView1.Rows[i].Cells[0].EditedFormattedValue.ToString() == "True")
                {
                    if (this.dataGridView1.Rows[i].Cells[7].Value.ToString() == "新增" ||
                        this.dataGridView1.Rows[i].Cells[7].Value.ToString() == "不通过")
                    {
                        if (this.usrKind != "业务员")
                        {
                            MessageBox.Show("用户权限不够!", "提示");
                            return;
                        }
                        //删除月计划
                        deletePlan d = new deletePlan(this.dataGridView1.Rows[i].Cells["ID"].Value.ToString(), "月");
                        bool       b = d.doDelete();

                        //得到对应周计划ID,删除对应周计划
                        String    qStr  = "select ID from WeekPlanning where planID = '" + this.dataGridView1.Rows[i].Cells["ID"].Value.ToString() + "'";
                        SQLquery  query = new SQLquery(qStr);
                        DataTable dt    = query.doSelect();
                        if (dt != null)
                        {
                            for (int j = 0; j < dt.Rows.Count; j++)
                            {
                                deletePlan d2 = new deletePlan(dt.Rows[j][0].ToString(), "周");
                                d2.doDelete();
                            }
                        }

                        if (b)
                        {
                            MessageBox.Show("删除月计划成功!", "提示");
                            this.dataGridView1.Rows.RemoveAt(i);
                            updateDataGridView();
                        }
                        else
                        {
                            MessageBox.Show("删除月计划失败!", "提示");
                        }
                    }
                    else
                    {
                        MessageBox.Show("该月计划不可删除!", "提示");
                    }
                }
            }
        }
Ejemplo n.º 9
0
        private void 审批单_Load(object sender, EventArgs e)
        {
            this.dataGridView1.AllowUserToAddRows = false;
            this.Text           = "上报" + kind + "计划审批";
            this.groupBox1.Text = "运输" + kind + "计划";
            this.lb_detail.Text = "运输" + kind + "计划详细信息";

            String    qs1 = "select * from " + knd + "Planning where ID = '" + this.id + "'";
            SQLquery  q1  = new SQLquery(qs1);
            DataTable dt1 = q1.doSelect();

            if (dt1 != null)
            {
                this.txt_cmp.Text = dt1.Rows[0][1].ToString();
                string tem = dt1.Rows[0][2].ToString();
                this.txt_zxsj.Text = tem.Substring(0, 4) + "-" + tem.Substring(4, 2) + "-" + tem.Substring(6, 2) + " 至 " + tem.Substring(0, 4) + "-" + tem.Substring(8, 2) + "-" + tem.Substring(10, 2);
                this.txt_type.Text = dt1.Rows[0][3].ToString();
                this.txt_hj.Text   = dt1.Rows[0][5].ToString();
                this.txt_cjr.Text  = dt1.Rows[0][6].ToString();
                this.txt_time.Text = dt1.Rows[0][7].ToString();
                this.txt_bz.Text   = dt1.Rows[0][8].ToString();
                this.txt_fj.Text   = dt1.Rows[0][9].ToString();
            }

            String    qs2 = "select * from PlanningDetail where planID = '" + this.id + "'";
            SQLquery  q2  = new SQLquery(qs2);
            DataTable dt2 = q2.doSelect();

            if (dt2 != null)
            {
                for (int i = 0; i < dt2.Rows.Count; i++)
                {
                    this.dataGridView1.Rows.Add(dt2.Rows[i][0].ToString(), dt2.Rows[i][1].ToString(), dt2.Rows[i][2].ToString(),
                                                dt2.Rows[i][3].ToString(), dt2.Rows[i][4].ToString(), dt2.Rows[i][5].ToString());
                }
            }

            String    qs3 = "select * from Approval where planID = '" + this.id + "'";
            SQLquery  q3  = new SQLquery(qs3);
            DataTable dt3 = q3.doSelect();

            if (dt3 != null)
            {
                this.txt_pfr.Text  = dt3.Rows[0][0].ToString();
                this.txt_pfrq.Text = dt3.Rows[0][1].ToString();
                this.txt_pfjd.Text = dt3.Rows[0][2].ToString();
                this.txt_pfyj.Text = dt3.Rows[0][3].ToString();
            }
        }
        private bool deleteSPD()
        {
            String   qStr3  = "delete from Approval where planID = '" + id + "'";
            SQLquery query3 = new SQLquery(qStr3);
            bool     b3     = query3.doModify();

            if (b3)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
        private bool deleteP()
        {
            //删除计划
            String   qStr  = "delete from " + kind + "Planning where ID = '" + id + "'";
            SQLquery query = new SQLquery(qStr);
            bool     b     = query.doModify();

            if (b)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
        private bool deleteJHMX()
        {
            //删除对应计划明细
            String   qStr1  = "delete from PlanningDetail where planID = '" + id + "'";
            SQLquery query1 = new SQLquery(qStr1);
            bool     b1     = query1.doModify();

            if (b1)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
        private bool deleteDDL()
        {
            //删除对应调度令
            String   qStr2  = "delete from Schedule where planID = '" + id + "'";
            SQLquery query2 = new SQLquery(qStr2);
            bool     b2     = query2.doModify();

            if (b2)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Ejemplo n.º 14
0
        private void btn_r_Click(object sender, EventArgs e)
        {
            if (this.txt_zh.Text == "" || this.txt_mm.Text == "" || this.txt_qrmm.Text == "" || this.cb_kind.Text == "")
            {
                MessageBox.Show("账号、密码或用户类型不能为空!", "错误");
                return;
            }

            if (this.txt_mm.Text != this.txt_qrmm.Text)
            {
                MessageBox.Show("确认密码不一致!", "错误");
                this.txt_qrmm.Text = "";
                return;
            }

            String    qStr  = "select * from Usr where account = '" + this.txt_zh.Text + "'";
            SQLquery  query = new SQLquery(qStr);
            DataTable dt    = query.doSelect();

            if (dt != null)
            {
                MessageBox.Show("账号已存在!", "错误");
                this.txt_zh.Text           = "";
                this.txt_mm.Text           = "";
                this.txt_qrmm.Text         = "";
                this.cb_kind.SelectedIndex = -1;
                return;
            }

            String qStr1 = "insert into Usr values('" + this.txt_zh.Text + "','" +
                           this.txt_mm.Text + "','" + this.cb_kind.Text + "')";
            SQLquery query1 = new SQLquery(qStr1);

            if (query1.doModify())
            {
                MessageBox.Show("用户注册成功!", "提示");
                this.txt_zh.Text           = "";
                this.txt_mm.Text           = "";
                this.txt_qrmm.Text         = "";
                this.cb_kind.SelectedIndex = -1;
                this.Close();
            }
            else
            {
                MessageBox.Show("用户注册失败!", "提示");
            }
        }
        private void 调度令详细信息_Load(object sender, EventArgs e)
        {
            this.dataGridView1.AllowUserToAddRows = false;
            String    qs2 = "select * from PlanningDetail where planID = '" + this.id + "'";
            SQLquery  q2  = new SQLquery(qs2);
            DataTable dt2 = q2.doSelect();

            if (dt2 != null)
            {
                for (int i = 0; i < dt2.Rows.Count; i++)
                {
                    this.dataGridView1.Rows.Add(dt2.Rows[i][0].ToString(), dt2.Rows[i][1].ToString(), dt2.Rows[i][2].ToString(),
                                                dt2.Rows[i][3].ToString(), dt2.Rows[i][4].ToString(), dt2.Rows[i][5].ToString());
                }
            }

            String    qs1 = "select * from TransportSchedule where planID = '" + this.id + "'";
            SQLquery  q1  = new SQLquery(qs1);
            DataTable dt1 = q1.doSelect();

            if (dt1 != null)
            {
                this.txt_flsj.Text    = dt1.Rows[0][0].ToString();
                this.txt_qfr.Text     = dt1.Rows[0][1].ToString();
                this.txt_zlzt.Text    = dt1.Rows[0][2].ToString();
                this.txt_jb.Text      = dt1.Rows[0][3].ToString();
                this.txt_jsrxm.Text   = dt1.Rows[0][4].ToString();
                this.txt_jsrczdh.Text = dt1.Rows[0][5].ToString();
                this.txt_flr.Text     = dt1.Rows[0][6].ToString();
                this.txt_flrczdh.Text = dt1.Rows[0][7].ToString();
            }

            String    qs3 = "select * from " + knd + "Planning where ID = '" + this.id + "'";
            SQLquery  q3  = new SQLquery(qs3);
            DataTable dt3 = q3.doSelect();

            if (dt3 != null)
            {
                this.txt_jsdw.Text = dt3.Rows[0][1].ToString();
                string tem = dt3.Rows[0][2].ToString();
                this.txt_zxsj.Text = tem.Substring(0, 4) + "-" + tem.Substring(4, 2) + "-" + tem.Substring(6, 2) + " 至 " + tem.Substring(0, 4) + "-" + tem.Substring(8, 2) + "-" + tem.Substring(10, 2);
                this.txt_hj.Text   = dt3.Rows[0][5].ToString();
                this.txt_bz.Text   = dt3.Rows[0][8].ToString();
                this.txt_fj.Text   = dt3.Rows[0][9].ToString();
            }
        }
Ejemplo n.º 16
0
        private void 运输月计划录入_Load(object sender, EventArgs e)
        {
            this.dataGridView1.AllowUserToAddRows = false;
            this.Text               = kind + "运输月计划录入";
            this.txt_time.Text      = DateTime.Now.ToLocalTime().ToString("yyyy-MM-dd hh:mm:ss");
            this.rb_g.Checked       = true;
            this.rb_railway.Checked = true;
            this.hjtxt              = 0;
            this.txt_hj.Text        = "0";

            for (int i = 1; i < 10; i++)
            {
                this.cb_y.Items.Add("0" + Convert.ToString(i));
            }
            this.cb_y.Items.Add(Convert.ToString(10));
            this.cb_y.Items.Add(Convert.ToString(11));
            this.cb_y.Items.Add(Convert.ToString(12));

            //对应年计划计划量减去此年计划下所有月计划量,为此次录入可用计划量
            String    qStr  = "select company,date,amount from YearPlanning where ID = '" + nid + "'";
            SQLquery  query = new SQLquery(qStr);
            DataTable dt    = query.doSelect();

            if (dt != null)
            {
                this.txt_cmp.Text  = dt.Rows[0][0].ToString();
                this.txt_year.Text = dt.Rows[0][1].ToString().Substring(0, 4);
                total = Convert.ToDouble(dt.Rows[0][2].ToString());
            }

            String    qStr4  = "select amount from MonthPlanning where planID = '" + nid + "'";
            SQLquery  query4 = new SQLquery(qStr4);
            DataTable dt4    = query4.doSelect();

            if (dt4 != null)
            {
                for (int i = 0; i < dt4.Rows.Count; i++)
                {
                    this.total -= Convert.ToDouble(dt4.Rows[i][0].ToString());
                }
            }
            MessageBox.Show("本年度运输计划还剩余计划量" + this.total + "吨", "提示");
        }
Ejemplo n.º 17
0
        private void btn_approve_Click(object sender, EventArgs e)
        {
            if (this.sp)
            {
                MessageBox.Show("该年计划已被审批过了!", "提示");
                return;
            }

            if (txt_pfyj.Text == "")
            {
                MessageBox.Show("请填写批复意见", "提示");
                return;
            }

            string decision = "通过";

            if (this.rb_no.Checked)
            {
                decision = "不通过";
            }

            String qStr = "insert into Approval values('" + this.txt_pfr.Text + "','" + this.txt_pfrq.Text +
                          "','" + decision + "','" + this.txt_pfyj.Text + "','" + this.id + "')";
            SQLquery query = new SQLquery(qStr);
            bool     b     = query.doModify();

            String   qStr1  = "update " + knd + "Planning set status = '" + decision + "' where ID = '" + this.id + "'";
            SQLquery query1 = new SQLquery(qStr1);
            bool     b1     = query1.doModify();

            if (b && b1)
            {
                MessageBox.Show("审批完成!", "提示");
                this.sp = true;
            }
            else
            {
                MessageBox.Show("审批失败!", "提示");
            }
        }
        private void updateDataGridView()
        {
            if (this.searchClick == true)
            {
                string sj   = this.year + this.month;
                String qStr = "select company,date,amount,type,status,ID from WeekPlanning where company " + (cmp != "" ? ("= '" + cmp + "'") : "is not null") +
                              " and date " + (sj != "" ? ("like '" + sj + "%'") : "is not null") + " and week " + (z != "" ? ("= " + z) : "> 0") +
                              " and type " + (ptype != "" ? (" = '" + ptype + "'") : "is not null") +
                              " and (status " + (statues != "" ? (" = '" + statues + "')") : (" <> '已下达' and status <> '未下达')"));

                if (this.usrKind == "审批员")
                {
                    qStr = "select company,date,amount,type,status,ID from WeekPlanning where company " + (cmp != "" ? ("= '" + cmp + "'") : "is not null") +
                           " and date " + (year != "" ? ("like '" + year + "%'") : "is not null") + " and week " + (z != "" ? ("= " + z) : "> 0") +
                           " and type " + (ptype != "" ? (" = '" + ptype + "'") : "is not null") +
                           " and (status " + (statues != "" ? (" = '" + statues + "')") : (" <> '已下达' and status <> '未下达' and status <> '新增')"));
                }
                SQLquery  query = new SQLquery(qStr);
                DataTable dt    = query.doSelect();
                if (dt == null)
                {
                    MessageBox.Show("未查到符合条件的记录!", "提示");
                }
                else
                {
                    this.dataGridView1.Rows.Clear();
                    this.dataGridView1.Update();

                    for (int i = 0; i < dt.Rows.Count; i++)
                    {
                        string tem = dt.Rows[i][1].ToString();
                        string st  = tem.Substring(0, 4) + "-" + tem.Substring(4, 2) + "-" + tem.Substring(6, 2);
                        string et  = tem.Substring(0, 4) + "-" + tem.Substring(8, 2) + "-" + tem.Substring(10, 2);
                        this.dataGridView1.Rows.Add("false", i + 1, dt.Rows[i][0].ToString(), st, et,
                                                    dt.Rows[i][2].ToString(), dt.Rows[i][3].ToString(), dt.Rows[i][4].ToString(), dt.Rows[i][5].ToString());
                    }
                }
            }
        }
        private void updateDataGridView()
        {
            if (this.searchClick == true)
            {
                string sj   = this.year + this.month;
                String qStr = "select company,date,amount,type,status,ID from MonthPlanning where company " + (cmp != "" ? ("= '" + cmp + "'") : "is not null") +
                              " and date " + (sj != "" ? ("like '" + sj + "%'") : "is not null") + " and type " + (ptype != "" ? (" = '" + ptype + "'") : "is not null") +
                              " and (status " + (statues != "" ? (" = '" + statues + "')") : (" = '已下达' or status = '未下达')"));

                SQLquery  query = new SQLquery(qStr);
                DataTable dt    = query.doSelect();
                if (dt == null)
                {
                    MessageBox.Show("未查到符合条件的记录!", "提示");
                }
                else
                {
                    this.dataGridView1.Rows.Clear();
                    this.dataGridView1.Update();

                    for (int i = 0; i < dt.Rows.Count; i++)
                    {
                        string tem = dt.Rows[i][1].ToString();
                        string st  = tem.Substring(0, 4) + "-" + tem.Substring(4, 2) + "-" + tem.Substring(6, 2);
                        string et  = tem.Substring(0, 4) + "-" + tem.Substring(8, 2) + "-" + tem.Substring(10, 2);
                        this.dataGridView1.Rows.Add("false", i + 1, dt.Rows[i][0].ToString(), st, et,
                                                    dt.Rows[i][2].ToString(), dt.Rows[i][3].ToString(), dt.Rows[i][4].ToString(), "下达", "录入", dt.Rows[i][5].ToString());

                        if (dt.Rows[i][4].ToString() != "未下达")
                        {
                            Font f = new Font("宋体", 9, FontStyle.Strikeout);
                            dataGridView1.Rows[i].Cells[8].Style.Font = f;
                        }
                    }
                }
            }
        }
Ejemplo n.º 20
0
        private void btn_login_Click(object sender, EventArgs e)
        {
            String    qStr  = "select password,type from Usr where account = '" + this.txt_account.Text + "'";
            SQLquery  query = new SQLquery(qStr);
            DataTable dt    = query.doSelect();

            if (dt == null)
            {
                MessageBox.Show("用户不存在!", "提示");
            }
            else if (dt.Rows[0][0].ToString() != this.txt_password.Text)
            {
                MessageBox.Show("密码错误!", "提示");
                this.txt_password.Text = "";
            }
            else if (dt.Rows[0][0].ToString() == this.txt_password.Text)
            {
                this.usrKind             = dt.Rows[0][1].ToString();
                this.txt_usrType.Text    = dt.Rows[0][1].ToString();
                this.txt_usrAccount.Text = this.txt_account.Text;
                this.menuEnabled         = true;
                menuEnable();
            }
        }
        private void btn_transmit_Click(object sender, EventArgs e)
        {
            if (this.dataGridView1.Rows.Count < 1 || this.txt_cmp.Text == "" || this.txt_year.Text == "" || this.cb_zs.Text == "")
            {
                MessageBox.Show("必填项(带*号)不能为空!", "提示");
            }
            else
            {
                //判断日期选择是否在范围内
                int pdyear = Convert.ToInt16(this.txt_year.Text);
                int pdmonth= Convert.ToInt16(this.txt_syue.Text);
                if (this.dateTimePicker1.Value.Year != pdyear || this.dateTimePicker1.Value.Month != pdmonth)
                {
                    MessageBox.Show("起始年月不在范围内!", "错误");
                    return;
                }

                if (this.dateTimePicker2.Value.Year != pdyear || this.dateTimePicker2.Value.Month != pdmonth)
                {
                    MessageBox.Show("结束年月不在范围内!", "错误");
                    return;
                }
                if (this.dateTimePicker1.Value.Day >= this.dateTimePicker2.Value.Day)
                {
                    MessageBox.Show("日期段异常!", "错误");
                    return;
                }

                int tag = 0;
                string type;
                if (this.rb_g.Checked)
                {
                    type = "普通";
                }
                else
                {
                    type = "追加";
                }
                double amount = 0;
                Guid u = System.Guid.NewGuid();
                string id = "Z-" + u;
                
                for (int i = 0; i < this.dataGridView1.Rows.Count; i++)
                {
                    String detail = "";
                    amount += Convert.ToDouble(this.dataGridView1.Rows[i].Cells[5].Value.ToString());
                    for (int j = 0; j < 5; j++)
                    {
                        detail += "'" + this.dataGridView1.Rows[i].Cells[j].Value.ToString() + "',";
                    }
                    detail += this.dataGridView1.Rows[i].Cells[5].Value.ToString();
                    String qStr = "insert into PlanningDetail values(" + detail + ",'" + id + "')";
                    SQLquery query = new SQLquery(qStr);
                    if (query.doModify())
                    {
                        if (i == this.dataGridView1.Rows.Count - 1)
                        {
                            tag += 1;
                            this.dataGridView1.Rows.Clear();
                        }
                    }
                }
                
                string statues;
                if (kind == "下达")
                {
                    statues = "未下达";
                }
                else
                {
                    statues = "新增";
                }

                string sday = this.dateTimePicker1.Value.Day.ToString();
                if (this.dateTimePicker1.Value.Day < 10)
                {
                    sday = "0" + sday;
                }
                string eday = this.dateTimePicker2.Value.Day.ToString();
                if (this.dateTimePicker1.Value.Day < 10)
                {
                    eday = "0" + eday;
                }
                

                string sj = this.txt_year.Text + this.txt_syue.Text + sday + this.txt_syue.Text + eday;
                String qStr1 = "insert into WeekPlanning values('" + id + "','" + this.txt_cmp.Text + "','" + sj
                        + "','" + type + "','" + statues + "'," + amount + ",'" + this.txt_cjr.Text + "','" + this.txt_time.Text + "','" + this.txt_bz.Text
                        + "','" + this.txt_fj.Text + "','" + this.yid + "',"+ this.cb_zs.Text +")";
                
                SQLquery query1 = new SQLquery(qStr1);
                if (query1.doModify())
                {
                    tag += 1;
                }

                if (tag == 2)
                {
                    MessageBox.Show("录入周计划成功!", "提示");
                    this.txt_cjr.Text = "系统管理员";
                    this.txt_bz.Text = "";
                    this.txt_fj.Text = "";
                    this.cb_zs.SelectedIndex = -1;
                    this.hjtxt = 0;
                    this.txt_hj.Text = "";
                    this.txt_time.Text = DateTime.Now.ToLocalTime().ToString("yyyy-MM-dd hh:mm:ss");
                    total -= amount;
                }
                else
                {
                    MessageBox.Show("录入周计划失败!", "提示");
                }
              
            }
        }
        private void btn_transmit_Click(object sender, EventArgs e)
        {
            if (this.dataGridView1.Rows.Count < 1 || this.txt_cmp.Text == "" || this.txt_year.Text == "")
            {
                MessageBox.Show("必填项(带*号)不能为空!", "提示");
            }
            else
            {
                if (!yearValid(this.txt_year.Text))
                {
                    MessageBox.Show("输入年份无效!", "错误");
                    this.txt_year.Text = "";
                    return;
                }

                this.txt_year.Text = Itrim(this.txt_year.Text);

                int    tag = 0;
                string type;
                if (this.rb_g.Checked)
                {
                    type = "普通";
                }
                else
                {
                    type = "追加";
                }
                double amount = 0;
                Guid   u      = System.Guid.NewGuid();
                string id     = "N-" + u;

                for (int i = 0; i < this.dataGridView1.Rows.Count; i++)
                {
                    String detail = "";
                    amount += Convert.ToDouble(this.dataGridView1.Rows[i].Cells[5].Value.ToString());
                    for (int j = 0; j < 5; j++)
                    {
                        detail += "'" + this.dataGridView1.Rows[i].Cells[j].Value.ToString() + "',";
                    }
                    detail += this.dataGridView1.Rows[i].Cells[5].Value.ToString();
                    String   qStr  = "insert into PlanningDetail values(" + detail + ",'" + id + "')";
                    SQLquery query = new SQLquery(qStr);
                    if (query.doModify())
                    {
                        if (i == this.dataGridView1.Rows.Count - 1)
                        {
                            tag += 1;
                            this.dataGridView1.Rows.Clear();
                        }
                    }
                }
                string statues;
                if (kind == "下达")
                {
                    statues = "未下达";
                }
                else
                {
                    statues = "新增";
                }

                string sj    = this.txt_year.Text + "01011231";
                String qStr1 = "insert into YearPlanning values('" + id + "','" + this.txt_cmp.Text + "','" + sj
                               + "','" + type + "','" + statues + "'," + amount + ",'" + this.txt_cjr.Text + "','" + this.txt_time.Text + "','" + this.txt_bz.Text
                               + "','" + this.txt_fj.Text + "')";

                SQLquery query1 = new SQLquery(qStr1);
                if (query1.doModify())
                {
                    tag += 1;
                }

                if (tag == 2)
                {
                    MessageBox.Show("录入年计划成功!", "提示");
                    this.txt_cmp.Text  = "";
                    this.txt_year.Text = "";
                    this.txt_cjr.Text  = "系统管理员";
                    this.txt_bz.Text   = "";
                    this.txt_fj.Text   = "";
                    this.hjtxt         = 0;
                    this.txt_hj.Text   = "";
                    this.txt_time.Text = DateTime.Now.ToLocalTime().ToString("yyyy-MM-dd hh:mm:ss");
                }
                else
                {
                    MessageBox.Show("录入年计划失败!", "提示");
                }
            }
        }
        private void btn_edit_Click(object sender, EventArgs e)
        {
            //判定计划量是否超出
            double tmpJHL = 0;

            for (int i = 0; i < this.dataGridView1.Rows.Count; i++)
            {
                tmpJHL += Convert.ToDouble(this.dataGridView1.Rows[i].Cells[5].Value.ToString());
            }
            if (this.kind == "年")
            {
                if ((totalMin * 10) > (tmpJHL * 10))
                {
                    MessageBox.Show("运输计划量低于其下月计划总量,请修改明细!", "错误");
                    return;
                }
            }
            else if (this.kind == "月")
            {
                if ((totalUp * 10) < (tmpJHL * 10))
                {
                    MessageBox.Show("运输计划量高于年计划剩余计划量,请修改明细!", "错误");
                    return;
                }
                if ((totalMin * 10) > (tmpJHL * 10))
                {
                    MessageBox.Show("运输计划量低于其下周计划总量,请修改明细!", "错误");
                    return;
                }
            }
            else if (this.kind == "周")
            {
                if ((totalUp * 10) < (tmpJHL * 10))
                {
                    MessageBox.Show("计划量不足,请修改明细!", "错误");
                    return;
                }
            }

            string fjhl = tmpJHL.ToString("0.0");

            bool b3 = false;
            bool b4 = false;
            //修改计划
            String qStr1 = "update " + knd + "Planning set amount = " + fjhl + ", creator = '" + this.txt_cjr.Text + "', remark = '" + this.txt_bz.Text
                           + "', attachment = '" + this.txt_fj.Text + "' where ID = '" + id + "'";
            SQLquery query1 = new SQLquery(qStr1);
            bool     b1     = query1.doModify();

            //删除计划明细
            String lid = "";

            for (int i = 0; i < ld.Count - 1; i++)
            {
                lid += ("'" + ld[i] + "' or ID = ");
            }
            lid += ("'" + ld[ld.Count - 1] + "'");
            String   qStr2  = "delete from PlanningDetail where ID = " + lid;
            SQLquery query2 = new SQLquery(qStr2);
            bool     b2     = query2.doModify();

            //修改计划明细
            for (int i = 0; i < this.dataGridView1.Rows.Count; i++)
            {
                string itid = this.dataGridView1.Rows[i].Cells["_ID"].Value.ToString();
                if (lm.Contains(itid))
                {
                    String qStr4 = "update PlanningDetail set forwarding_unit = '" + this.dataGridView1.Rows[i].Cells[0].Value.ToString()
                                   + "', transportation = '" + this.dataGridView1.Rows[i].Cells[1].Value.ToString() + "', consignee = '" +
                                   this.dataGridView1.Rows[i].Cells[2].Value.ToString() + "', receiptPlace = '" + this.dataGridView1.Rows[i].Cells[3].Value.ToString()
                                   + "', address = '" + this.dataGridView1.Rows[i].Cells[4].Value.ToString() + "', amount = " +
                                   this.dataGridView1.Rows[i].Cells[5].Value.ToString() + " where ID = '" + itid + "'";
                    SQLquery query4 = new SQLquery(qStr4);
                    b4 = query4.doModify();
                }
            }

            //新增计划明细
            for (int i = 0; i < this.dataGridView1.Rows.Count; i++)
            {
                if (this.dataGridView1.Rows[i].Cells["_ID"].Value.ToString() == "")
                {
                    String detail = "";
                    for (int j = 0; j < 5; j++)
                    {
                        detail += "'" + this.dataGridView1.Rows[i].Cells[j].Value + "',";
                    }
                    detail += this.dataGridView1.Rows[i].Cells[5].Value;
                    String   qStr3  = "insert into PlanningDetail values(" + detail + ",'" + this.id + "')";
                    SQLquery query3 = new SQLquery(qStr3);
                    b3 = query3.doModify();
                }
            }

            if (b1 || b2 || b3 || b4)
            {
                MessageBox.Show("修改" + kind + "计划成功!", "提示");
            }
            else if (!b1 && !b2 && !b3 && !b4)
            {
                MessageBox.Show("未修改" + kind + "计划!", "提示");
            }
            else
            {
                MessageBox.Show("修改" + kind + "计划失败!", "提示");
            }
        }
        private void 运输计划修改_Load(object sender, EventArgs e)
        {
            this.dataGridView1.AllowUserToAddRows = false;
            this.Text           = "运输" + kind + "计划修改";
            this.groupBox1.Text = "运输" + kind + "计划";
            ld = new List <string>();
            lm = new List <string>();
            this.rb_railway.Checked = true;
            this.hjtxt    = 0;
            this.totalMin = 0;
            this.totalUp  = 0;

            String    qs1 = "select * from " + knd + "Planning where ID = '" + this.id + "'";
            SQLquery  q1  = new SQLquery(qs1);
            DataTable dt1 = q1.doSelect();

            if (dt1 != null)
            {
                this.txt_cmp.Text = dt1.Rows[0][1].ToString();
                string tem = dt1.Rows[0][2].ToString();
                this.txt_zxsj.Text = tem.Substring(0, 4) + "-" + tem.Substring(4, 2) + "-" + tem.Substring(6, 2) + " 至 " + tem.Substring(0, 4) + "-" + tem.Substring(8, 2) + "-" + tem.Substring(10, 2);
                this.txt_type.Text = dt1.Rows[0][3].ToString();
                this.txt_cjr.Text  = dt1.Rows[0][6].ToString();
                this.txt_time.Text = dt1.Rows[0][7].ToString();
                this.txt_bz.Text   = dt1.Rows[0][8].ToString();
                this.txt_fj.Text   = dt1.Rows[0][9].ToString();

                if (this.kind == "年")
                {
                    //其下所以月计划量之和为计划量下限
                    String    qStr2  = "select amount from MonthPlanning where planID = '" + this.id + "'";
                    SQLquery  query2 = new SQLquery(qStr2);
                    DataTable dt2    = query2.doSelect();
                    if (dt2 != null)
                    {
                        this.totalMin = Convert.ToDouble(dt2.Rows[0][0].ToString());
                    }
                }
                else if (this.kind == "月")
                {
                    //其下所以月计划量之和为计划量下限
                    String    qStr5  = "select amount from WeekPlanning where planID = '" + this.id + "'";
                    SQLquery  query5 = new SQLquery(qStr5);
                    DataTable dt5    = query5.doSelect();
                    if (dt5 != null)
                    {
                        this.totalMin = Convert.ToDouble(dt5.Rows[0][0].ToString());
                    }

                    //对应年计划计划量减去此年计划下所有其他月计划量,为计划量上限
                    String    qStr2  = "select amount from YearPlanning where ID = '" + dt1.Rows[0][10].ToString() + "'";
                    SQLquery  query2 = new SQLquery(qStr2);
                    DataTable dt2    = query2.doSelect();
                    if (dt2 != null)
                    {
                        this.totalUp = Convert.ToDouble(dt2.Rows[0][0].ToString());
                    }

                    String    qStr4  = "select ID,amount from MonthPlanning where planID = '" + dt1.Rows[0][10].ToString() + "'";
                    SQLquery  query4 = new SQLquery(qStr4);
                    DataTable dt4    = query4.doSelect();
                    if (dt4 != null)
                    {
                        for (int i = 0; i < dt4.Rows.Count; i++)
                        {
                            if (this.id != dt4.Rows[i][0].ToString())
                            {
                                this.totalUp -= Convert.ToDouble(dt4.Rows[i][1].ToString());
                            }
                        }
                    }
                }
                else if (this.kind == "周")
                {
                    String    qStr2  = "select amount from MonthPlanning where ID = '" + dt1.Rows[0][10].ToString() + "'";
                    SQLquery  query2 = new SQLquery(qStr2);
                    DataTable dt2    = query2.doSelect();
                    if (dt2 != null)
                    {
                        this.totalUp = Convert.ToDouble(dt2.Rows[0][0].ToString());
                    }

                    String    qStr4  = "select ID,amount from WeekPlanning where planID = '" + dt1.Rows[0][10].ToString() + "'";
                    SQLquery  query4 = new SQLquery(qStr4);
                    DataTable dt4    = query4.doSelect();
                    if (dt4 != null)
                    {
                        for (int i = 0; i < dt4.Rows.Count; i++)
                        {
                            if (this.id != dt4.Rows[i][0].ToString())
                            {
                                this.totalUp -= Convert.ToDouble(dt4.Rows[i][1].ToString());
                            }
                        }
                    }
                }
            }

            String    qs3 = "select * from PlanningDetail where planID = '" + this.id + "'";
            SQLquery  q3  = new SQLquery(qs3);
            DataTable dt3 = q3.doSelect();

            if (dt3 != null)
            {
                for (int i = 0; i < dt3.Rows.Count; i++)
                {
                    this.dataGridView1.Rows.Add(dt3.Rows[i][0].ToString(), dt3.Rows[i][1].ToString(), dt3.Rows[i][2].ToString(),
                                                dt3.Rows[i][3].ToString(), dt3.Rows[i][4].ToString(), dt3.Rows[i][5].ToString(), "删除", dt3.Rows[i][7].ToString());
                    hjtxt += Convert.ToDouble(dt3.Rows[i][5].ToString());
                }
            }
            this.txt_hj.Text = hjtxt.ToString("0.0");
            this.isLoad      = true;
        }