Ejemplo n.º 1
0
        public void change_checksheet(WebHelper w, Dictionary <string, object> kv)
        {
            Model.ic_t_check_master ord = w.GetObject <Model.ic_t_check_master>();
            ord.approve_flag = "0";
            ord.max_change   = 0;

            List <Model.ic_t_check_detail> lines = w.GetList <Model.ic_t_check_detail>("lines");

            bll.ChangeCheckSheet(ord, lines);
        }
Ejemplo n.º 2
0
        public void add_checksheet(WebHelper w, Dictionary <string, object> kv)
        {
            Model.ic_t_check_master ord = w.GetObject <Model.ic_t_check_master>();
            ord.approve_flag = "0";
            ord.max_change   = 0;

            List <Model.ic_t_check_detail> lines = w.GetList <Model.ic_t_check_detail>("lines");

            string sheet_no = "";

            bll.AddCheckSheet(ord, lines, out sheet_no);

            w.Write("sheet_no", sheet_no);
        }
Ejemplo n.º 3
0
        void IBLL.ICheckBLL.AddCheckSheet(Model.ic_t_check_master ord, List <Model.ic_t_check_detail> lines, out string sheet_no)
        {
            ReadWriteContext.IWriteContext w = new ReadWriteContext.WriteContextByJson();
            w.Append("sheet_no", ord.sheet_no);
            w.Append("branch_no", ord.branch_no);
            w.Append("check_no", ord.check_no);
            w.Append("meno", ord.meno);
            w.Append("oper_id", ord.oper_id);
            w.Append("deal_man", ord.deal_man);
            w.Append("cm_branch", ord.cm_branch);
            w.Append("oper_date", ord.oper_date.ToString("yyyy-MM-dd HH:mm:ss"));

            var tb = new DataTable();

            tb.Columns.Add("sheet_no");
            tb.Columns.Add("item_no");
            tb.Columns.Add("in_price", typeof(decimal));
            tb.Columns.Add("sale_price", typeof(decimal));
            tb.Columns.Add("stock_qty", typeof(decimal));
            tb.Columns.Add("real_qty", typeof(decimal));
            tb.Columns.Add("balance_qty", typeof(decimal));
            tb.Columns.Add("memo");
            tb.Columns.Add("other1");
            tb.Columns.Add("other2");
            tb.Columns.Add("num1", typeof(decimal));
            tb.Columns.Add("num2", typeof(decimal));
            tb.Columns.Add("num3", typeof(decimal));
            tb.Columns.Add("packqty", typeof(int));
            tb.Columns.Add("sgqty", typeof(decimal));
            foreach (Model.ic_t_check_detail line in lines)
            {
                tb.Rows.Add(line.sheet_no, line.item_no, line.in_price, line.sale_price, line.stock_qty, line.real_qty, line.balance_qty,
                            line.memo, line.other1, line.other2, line.num1, line.num2, line.num3, line.packqty, line.sgqty);
            }
            w.Append("lines", tb);
            Helper.IRequest req  = new Helper.Request();
            var             json = req.request("/check?t=add_checksheet", w.ToString());

            ReadWriteContext.IReadContext r = new ReadWriteContext.ReadContextByJson(json);
            if (r.Read("errId") != "0")
            {
                throw new Exception(r.Read("errMsg"));
            }
            sheet_no = r.Read("sheet_no");
        }
Ejemplo n.º 4
0
        void ICheckBLL.ChangeCheckSheet(Model.ic_t_check_master ord, List <Model.ic_t_check_detail> lines)
        {
            var db = new DB.DBByHandClose(Appsetting.conn);

            DB.IDB d = db;
            try
            {
                db.Open();

                db.BeginTran();
                //
                string sql = "select approve_flag,update_time from ic_t_check_master where sheet_no='" + ord.sheet_no + "'";
                var    tb  = d.ExecuteToTable(sql, null);
                if (tb.Rows.Count == 0)
                {
                    throw new Exception("单据不存在[" + ord.sheet_no + "]");
                }
                else
                {
                    var row = tb.Rows[0];
                    if (row["approve_flag"].ToString() == "1")
                    {
                        throw new Exception("单据已审核[" + ord.sheet_no + "]");
                    }
                    if (Helper.Conv.ToDateTime(row["update_time"]) > ord.update_time)
                    {
                        throw new Exception("单据已被他人修改[" + ord.sheet_no + "]");
                    }
                }
                DataTable finfishtb = d.ExecuteToTable("select * from ic_t_check_detail where sheet_no='" + ord.sheet_no + "' ", null);

                sql = "delete from ic_t_check_detail where sheet_no='" + ord.sheet_no + "'";
                d.ExecuteScalar(sql, null);
                sql = "delete from ic_t_check_master where sheet_no='" + ord.sheet_no + "'";
                d.ExecuteScalar(sql, null);
                //
                ord.update_time = DateTime.Now;
                d.Insert(ord);
                foreach (Model.ic_t_check_detail line in lines)
                {
                    sql          = "select isnull(max(flow_id),0) + 1 as flow_id from ic_t_check_detail ";
                    line.flow_id = Helper.Conv.ToInt64(d.ExecuteScalar(sql, null));
                    d.Insert(line);

                    var finfish = d.ExecuteToModel <ic_t_check_finish>("select * from ic_t_check_finish where sheet_no='" + ord.check_no + "' and item_no='" + line.item_no + "'", null);
                    if (finfish == null)
                    {
                        finfish = new ic_t_check_finish()
                        {
                            sheet_no    = ord.check_no,
                            item_no     = line.item_no,
                            branch_no   = ord.branch_no,
                            change_flag = "1",
                            sale_price  = line.sale_price,
                            stock_qty   = line.stock_qty,
                            create_time = DateTime.Now,
                            in_price    = line.in_price,
                            memo        = line.memo,
                            real_qty    = line.real_qty,
                            update_time = DateTime.Now,
                        };
                        d.Insert(finfish);
                    }
                    else
                    {
                        DataRow t = finfishtb.Select().Where(a => a["item_no"].ToString().Equals(finfish.item_no)).SingleOrDefault();
                        finfish.real_qty += line.real_qty;
                        if (t != null)
                        {
                            finfish.real_qty -= Conv.ToDecimal(t["real_qty"]);
                        }
                        finfish.update_time = DateTime.Now;
                        d.Update(finfish, "sheet_no,item_no");
                    }
                }
                //
                db.CommitTran();
            }
            catch (Exception ex)
            {
                Log.writeLog("CheckBLL.ChangeCheckSheet()", ex.ToString(), ord.sheet_no);
                db.RollBackTran();
                throw ex;
            }
            finally
            {
                db.Close();
            }
        }
Ejemplo n.º 5
0
        void ICheckBLL.AddCheckSheet(Model.ic_t_check_master ord, List <Model.ic_t_check_detail> lines, out string sheet_no)
        {
            sheet_no = "";
            var db = new DB.DBByHandClose(Appsetting.conn);

            DB.IDB d = db;
            try
            {
                db.Open();

                db.BeginTran();
                sheet_no        = MaxCode(d, "PD");
                ord.sheet_no    = sheet_no;
                ord.create_time = DateTime.Now;
                ord.update_time = ord.create_time;
                //
                d.Insert(ord);

                foreach (Model.ic_t_check_detail line in lines)
                {
                    var bak = d.ExecuteToModel <ic_t_check_bak>("select * from ic_t_check_bak where sheet_no='" + ord.check_no + "' and item_no='" + line.item_no + "' ", null);
                    if (bak != null)
                    {
                        line.stock_qty   = bak.stock_qty;
                        line.in_price    = bak.price;
                        line.sale_price  = bak.sale_price;
                        line.balance_qty = line.real_qty - line.stock_qty;
                    }
                    string sql = "select isnull(max(flow_id),0) + 1 as flow_id from ic_t_check_detail ";
                    line.flow_id  = Helper.Conv.ToInt64(d.ExecuteScalar(sql, null));
                    line.sheet_no = sheet_no;
                    d.Insert(line);

                    var finfish = d.ExecuteToModel <ic_t_check_finish>("select * from ic_t_check_finish where sheet_no='" + ord.check_no + "' and item_no='" + line.item_no + "'", null);
                    if (finfish == null)
                    {
                        finfish = new ic_t_check_finish()
                        {
                            sheet_no    = ord.check_no,
                            item_no     = line.item_no,
                            branch_no   = ord.branch_no,
                            change_flag = "1",
                            sale_price  = line.sale_price,
                            stock_qty   = line.stock_qty,
                            create_time = DateTime.Now,
                            in_price    = line.in_price,
                            memo        = line.memo,
                            real_qty    = line.real_qty,
                            update_time = DateTime.Now,
                        };
                        d.Insert(finfish);
                    }
                    else
                    {
                        finfish.real_qty   += line.real_qty;
                        finfish.update_time = DateTime.Now;
                        d.Update(finfish, "sheet_no,item_no");
                    }
                }
                //
                db.CommitTran();
            }
            catch (Exception ex)
            {
                Log.writeLog("CheckBLL.AddCheckSheet()", ex.ToString(), ord.sheet_no);
                db.RollBackTran();
                throw ex;
            }
            finally
            {
                db.Close();
            }
        }