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("该周计划不可提交!", "提示");
                    }
                }
            }
        }
Exemple #2
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("下达调度令失败!", "提示");
            }
        }
        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 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);
            }
        }
        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);
            }
        }
Exemple #7
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("用户注册失败!", "提示");
            }
        }
Exemple #8
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 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 + "计划失败!", "提示");
            }
        }