コード例 #1
0
ファイル: FrmTasksplit.cs プロジェクト: hxchz/JTInterface
        private void save_old()
        {
            UserDao dao = new UserDao();
            if (BLL.string_1(dgv_1.CurrentRow.Cells["no_productorder"].Value) != BLL.string_1(txt_no_product__2.Text))
            {
                MessageBox.Show("任务单与选中任务单不一致");
                return;
            }
            if (BLL.string_1(this.cmb_no_car.SelectedValue) != "")
            {
                //string no_car_select = BLL.string_1(this.cmb_no_car.SelectedValue);
                //string sql_no_car_come = "select no_car_come from ls_car where no_ls='" + no_car_select + "'";
                //string no_car_come = dao.GetScalar_s(sql_no_car_come);
                //if (no_car_come == "01")
                //{
                //    if (BLL.string_1(this.cmb_no_driver.SelectedValue) == "")
                //    {
                //        MessageBox.Show("驾驶员不能为空");
                //        return;
                //    }
                //}
            }
            if (budan == "")
            {
                this_edit.ds.Tables["head"].Rows[0]["date_make"] = Convert.ToDateTime(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
                this_edit.ds.Tables["head"].Rows[0]["date_bill"] = this_edit.ds.Tables["head"].Rows[0]["date_make"];

                string sql_peibidan = "select count(*) from ls_send where no_productorder='" + BLL.string_1(dgv_1.CurrentRow.Cells["no_productorder"].Value) + "' and date_bill>dateadd(day,-3,getdate())";
                int count_pro = Convert.ToInt32(dao.GetScalar(sql_peibidan));
                if (count_pro <= 1)
                {
                    MessageBox.Show("当前任务单第一车,注意带配比单!!!");
                    MessageBox.Show("当前任务单第一车,注意带配比单!!!");
                    MessageBox.Show("当前任务单第一车,注意带配比单!!!");
                }
            }
            else if (budan == "budan")
            {
                this_edit.ds.Tables["head"].Rows[0]["date_make"] = dtp_date_make.Value.ToString("yyyy-MM-dd HH:mm:ss");
                this_edit.ds.Tables["head"].Rows[0]["date_bill"] = this_edit.ds.Tables["head"].Rows[0]["date_make"];
            }
            this_edit.ds.Tables["head"].Rows[0]["distance_car"] = BLL.decimal_1(dgv_1.CurrentRow.Cells["distance_car"].Value);
            if (BLL.decimal_1(dgv_1.CurrentRow.Cells["distance_car"].Value) == 0M)
            {
                MessageBox.Show("没有运距,不能发货");
                return;
            }
            this.label17.Focus();

            if (txt_qty_send.Text == null || txt_qty_send.Text == "" || BLL.decimal_1(txt_qty_send.Text) == 0)
            {
                if (MessageBox.Show("没有有效发货数量,确定要发货吗? “是”确定发货,“否”返回修改", "发货提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No) { return; }

                decimal qty_send = BLL.decimal_1(txt_qty_send.Text);
                if (BLL.decimal_1(txt_qty_fact.Text) == 0 && qty_send == 0)
                {
                    MessageBox.Show("方量为零,禁止保存!");
                    return;
                }
            }
            {
                decimal qty_fact = BLL.decimal_1(this.txt_qty_fact.Text);
                decimal qty_from = BLL.decimal_1(this.txt_qty_from.Text);
                decimal qty_send = qty_fact + qty_from;
                decimal qty_send_total = sumQty2 + qty_send;
                decimal qty_leiji = sumQty + qty_send;
                this.txt_qty_send.Text = BLL.string_1(qty_send);
                this.txt_qty_send.DataBindings[0].WriteValue();
                this.txt_qty_send_total.Text = BLL.string_1(qty_send_total);
                this.txt_qty_send_total.DataBindings[0].WriteValue();
                this.txt_qty_leiji.Text = BLL.string_1(qty_leiji);
                this.txt_qty_leiji.DataBindings[0].WriteValue();
            }

            string sql = "";
            sql = String.Format("select no_send_control from ls_hetong where no_bill='{0}'", txt_no_hetong.Text.Trim());

            string no_productorder = BLL.string_1(dgv_1.CurrentRow.Cells["no_productorder"].Value);
            if (this_edit.save(0, 1))
            {
                if (cmb_no_fahuolou.Text == "")
                {
                    return;
                }
                string no_fahuolou = this.cmb_no_fahuolou.SelectedValue.ToString();
                DateTime aa = DateTime.Now;
                string date_a = aa.ToString("yyyy-MM-dd");
                string date_b = aa.ToString("yyyy-MM-dd") + " 23:59:59";
                sql = string.Format("select max(date_bill) as date_max from ls_send where date_bill between '{0}' and '{1}' and no_bill!='{2}'", date_a, date_b, BLL.string_1(this_edit.ds.Tables["head"].Rows[0]["no_bill"]));
                string date_last = dao.GetScalar_s(sql);

                DateTime bb = aa;
                if (date_last != null && date_last != "")
                {
                    bb = Convert.ToDateTime(date_last);
                }
                DateTime cc = Convert.ToDateTime(this.dtp_date_make.Text);
                TimeSpan tms = cc - bb;
                int min = tms.Minutes + tms.Days * 1440 + tms.Hours * 60;
                sql = string.Format("select count(*) from ls_send where date_bill between '{0}' and '{1}' and no_fahuolou='{2}'", date_a, date_b, no_fahuolou);
                if (Convert.ToInt32(dao.GetScalar(sql)) == 0)
                {
                    //sql = string.Format("update ls_fahuolou set time_jiange='{0}' where no_ls='{1}'", min, no_fahuolou);
                    // dao.ExecuteCommand(sql);
                }
                else
                {
                    sql = string.Format("select time_jiange from ls_fahuolou where no_ls='{0}'", no_fahuolou);
                    if (min > Convert.ToInt32(dao.GetScalar(sql)))
                    {
                        //sql = string.Format("update ls_fahuolou set time_jiange='{0}' where no_ls='{1}'", min, no_fahuolou);
                        //dao.GetScalar(sql);
                    }
                }
                //sql = string.Format("update ls_fahuolou set time_lastsend='{0}',qty_fact='{1}' where no_ls='{2}'", Convert.ToDateTime(this_edit.ds.Tables["head"].Rows[0]["date_make"]), BLL.decimal_1(txt_qty_send_total.Text), no_fahuolou);
                //dao.GetScalar(sql);

                //修改车辆状态为出厂(01:入厂  02出厂)
                if (cmb_no_car.Text == "")
                {
                    return;
                }
                string no_car = this.cmb_no_car.SelectedValue.ToString();
                if (budan != "budan")
                {
                    //sql = string.Format("update ls_car set no_car_state='02',no_driver='{0}',time_lastsend='{1}',name_product='{2}' where no_ls='{3}'", BLL.string_1(this.cmb_no_driver.SelectedValue), Convert.ToDateTime(this_edit.ds.Tables["head"].Rows[0]["date_make"]), BLL.string_1(txt_no_productorder__1__3.Text), no_car);
                    //dao.GetScalar(sql);
                }
                //赋值
                string no_bill = this_edit.no_bill;

                //                if (dgv_1.CurrentRow != null)
                //                {
                //                    if (no_bill != "")
                //                    {

                //                        draw_print a = new draw_print();
                //                        DataTable dt_1;
                //                        string sql_1 = @"select a.no_bill,c.no_bill_in as no_hetong,a.distance_car,c.name_product,d.name_company,
                //                    case when a.qty_send=a.qty_shajiang then e.name_qiangdu_ranks+'砂浆' when b.qty_chanheliao1=0 then e.name_qiangdu_ranks when a.qty_shajiang=0 then  e.name_qiangdu_ranks+' '+convert(varchar,b.qty_chanheliao1)+'%'+j.name_chanheliao else e.name_qiangdu_ranks end as name_qiangdu_ranks,f.name_type_bengsong,isnull(g.name_tanluodu,'') as name_tanluodu,
                //                    isnull(h.name_fahuolou,'') as name_fahuolou,case when a.qty_shajiang>0 and a.qty_shajiang<a.qty_send then  convert(varchar,a.qty_send)+'('+convert(varchar,a.qty_send)+'含'+convert(varchar,a.qty_shajiang)+')' when (a.qty_shajiang=0 or a.qty_shajiang=a.qty_send) then convert(varchar,a.qty_send) end as qty_send,a.qty_leiji,
                //                    a.no_car,i.name_driver,c.addr_sign,
                //                    convert(varchar(10),a.date_bill,121) as date_bill,a.person_make as pet_name,a.shigongbuwei,
                //                    convert(varchar(12),a.date_bill,108) as time_bill,a.remark,a.no_productorder,b.other,j.name_chanheliao,isnull(b.linktel,'') as linktel
                //                    from ls_send a
                //                    join ls_productorder b on a.no_productorder=b.no_bill
                //                    join ls_hetong c on b.no_hetong=c.no_bill
                //                    join ls_shengoudan k on c.no_bill=k.no_hetong
                //                    join ls_company d on c.no_company=d.no_ls
                //                    join ls_qiangdu_ranks e on a.no_qiangdu_ranks=e.no_ls
                //                    join ls_type_bengsong f on a.no_type_bengsong=f.no_ls
                //                    left join ls_tanluodu g on b.no_tanluodu=g.no_ls
                //                    left join ls_fahuolou h on a.no_fahuolou=h.no_ls
                //                    left join ls_driver i on a.no_driver=i.no_ls
                //                    left join ls_chanheliao j on b.no_chanheliao1=j.no_ls
                //                    where a.no_bill='" + no_bill + @"'";
                //                        string sql_2_1 = string.Format(@"select no_productorder,case when qty_send < 0 then -1 when qty_send > 0 then 1 end as checi, isnull(qty_send,0) as
                //            qty_send from ls_send where no_productorder='" + no_productorder + "'");
                //                        string sql_2 = string.Format(@"select no_productorder , sum(checi) as checi, sum(qty_send) as qty_total from ({0}) a group by no_productorder", sql_2_1);

                //                        string sql_3 = "select sql_1.*,sql_2.* from (" + sql_1 + ")sql_1 left join (" + sql_2 + ")sql_2 on sql_1.no_productorder=sql_2.no_productorder";
                //                        dt_1 = db.GetDataSet(sql_3);
                //                        string sql_4_1 = string.Format("select 'a' as a,count(*) as checi_total from ls_send where date_bill between '" + DateTime.Now.ToShortDateString() + " 00:00:00" + "' and '" + DateTime.Now.ToShortDateString() + " 23:59:59" + "' and no_fahuolou='{0}'", BasicInfo.DataBase.no_fahuolou);
                //                        string sql_4_2 = string.Format("select 'a' as a,count(*)+count(*) as checi_total from ls_send where date_bill between '" + DateTime.Now.ToShortDateString() + " 00:00:00" + "' and '" + DateTime.Now.ToShortDateString() + " 23:59:59" + "' and ls_send.qty_send < 0 and no_fahuolou='{0}'", BasicInfo.DataBase.no_fahuolou);
                //                        string sql_4 = string.Format("select sql_4_1.checi_total - isnull(sql_4_2.checi_total,0) as checi_total from ({0})sql_4_1 left join ({1})sql_4_2 on sql_4_1.a=sql_4_2.a", sql_4_1, sql_4_2);
                //                        DataTable dt_2 = db.GetDataSet(sql_4);
                //                        a.add_dt_head(dt_1, 0);
                //                        a.add_dt_head(dt_2, 0);
                //                        config_function.print_do(a, this.Name);
                //                    }
                //                }

                no_send = no_bill;
                this_edit.reload_no_bill(null);
            }
            //btn_add.PerformClick();
            //car_load();
        }
コード例 #2
0
ファイル: FrmTasksplit.cs プロジェクト: hxchz/JTInterface
        private void send_mx_load()
        {
            UserDao dao = new UserDao();
            //this_edit.ds.Tables["head"].Rows[0]["no_productorder"] = this.dgv_1.CurrentRow.Cells["no_productorder"].Value.ToString().Trim();
            //this_edit.ds.Tables["head"].Rows[0]["shigongbuwei"] = BLL.string_1(this.dgv_1.CurrentRow.Cells["shigongbuwei"].Value);
            //this_edit.ds.Tables["head"].Rows[0]["distance_car"] = BLL.decimal_1(dgv_1.CurrentRow.Cells["distance_car"].Value);
            txt_distance_car.Text = dgv_1.CurrentRow.Cells["distance_car"].Value.ToString();
            decimal yudingQty = decimal.Parse(this.dgv_1.CurrentRow.Cells["qty_yuding"].Value.ToString());//预定数量
            this.txt_no_product__2.Text = this.dgv_1.CurrentRow.Cells["no_productorder"].Value.ToString().Trim();
            this.txt_no_hetong.Text = this.dgv_1.CurrentRow.Cells["no_hetong"].Value.ToString().Trim();
            this.txt_no_productorder__1__4.Text = this.dgv_1.CurrentRow.Cells["no_bill_in"].Value.ToString().Trim();
            this.textBox6.Text = this.dgv_1.CurrentRow.Cells["shigongbuwei"].Value.ToString().Trim();
            this.textBox7.Text = this.dgv_1.CurrentRow.Cells["no_type_bengsong"].Value.ToString().Trim();

            this.txt_peibidan.Text = this.dgv_1.CurrentRow.Cells["no_peibidan"].Value.ToString().Trim();
            //this.txt_no_productorder__1__2__2.Text = this.dgv_1.CurrentRow.Cells["name_company"].Value.ToString().Trim();
            //this.txt_no_productorder__1__3.Text = this.dgv_1.CurrentRow.Cells["name_product"].Value.ToString().Trim();
            //this.txt_no_productorder__1.Text = this.dgv_1.CurrentRow.Cells["shigongbuwei"].Value.ToString().Trim();
            this.cmb_no_type_bengsong.SelectedValue = this.dgv_1.CurrentRow.Cells["name_type_bengsong"].Value.ToString().Trim();
            this.cmb_no_type_bengsong.Text = this.dgv_1.CurrentRow.Cells["name_type_bengsong"].Value.ToString().Trim();
            if (this.cmb_no_type_bengsong.SelectedValue == "01")
            {
                //2011-06-14注释,模式变动,打泵改成从发货单做
                this.cmb_no_benghao.Enabled = false;
                this.cmb_no_bengrenyuan.Enabled = false;
            }
            else
            {
                //泵送非泵送的都不用输入泵人员
                this.cmb_no_benghao.Enabled = true;
                this.cmb_no_bengrenyuan.Enabled = true;
                if (this.dgv_1.CurrentRow.Cells["no_benghao"].Value != null && this.dgv_1.CurrentRow.Cells["no_benghao"].Value.ToString().Trim() != "")
                {
                    this.cmb_no_benghao.SelectedValue = this.dgv_1.CurrentRow.Cells["no_benghao"].Value.ToString().Trim();
                    this.cmb_no_bengrenyuan.SelectedValue = this.dgv_1.CurrentRow.Cells["no_bengrenyuan"].Value.ToString().Trim();
                }
            }
            this.cmb_no_qiangdu_ranks.SelectedValue = dgv_1.CurrentRow.Cells["name_qiangdu_ranks"].Value.ToString().Trim();
            this.cmb_no_qiangdu_ranks.Text = dgv_1.CurrentRow.Cells["name_qiangdu_ranks"].Value.ToString().Trim();
            //获取是否灌桩
            if (this.dgv_1.CurrentRow.Cells["name_guanzhuang"].Value.ToString() == "")
            {

            }
            else
            {
                string sql = string.Format("select no_ls from ls_guanzhuang where name_guanzhuang='{0}'", this.dgv_1.CurrentRow.Cells["name_guanzhuang"].Value.ToString().Trim());
                this.cmb_no_guanzhuang.SelectedValue = dao.GetScalar_s(sql);
            }
            txt_no_bill.Text = dao.no_bill("","ls_send_yupai");
        }
コード例 #3
0
ファイル: FrmTasksplit.cs プロジェクト: hxchz/JTInterface
        private void leijiQty_pd()
        {
            UserDao dao = new UserDao();
            string sql = String.Format("select no_send_control from ls_hetong where no_bill='{0}'", txt_no_hetong.Text.Trim());

            //判断选中的合同发货控制类型(01先款后货  02其他)
            if (dao.GetScalar_s(sql) == "01")
            {
                leijiQty_2 = dao.GetScalar_d("select sum(qty_send)-sum(qty_back)-sum(qty_baofei)-sum(qty_zy) from ls_send where no_productorder ='" + this.dgv_1.CurrentRow.Cells["no_productorder"].Value.ToString().Trim() + "'");
                if (leijiQty_2 >= yudingQty)
                {
                    MessageBox.Show("发货数量已经超出预定数量,不允许发货");
                    this.is_ok = false;
                }
            }
            if (this.is_ok)
            {
            }
            else
            {
                this.btn_save2.Enabled = false;
            }
            this.is_ok = true;
        }