Example #1
0
        public void add_salesheet(WebHelper w, Dictionary <string, object> kv)
        {
            Model.sm_t_salesheet ord = w.GetObject <Model.sm_t_salesheet>();
            ord.approve_flag = "0";
            ord.source_flag  = "";
            ord.approve_man  = "";
            ord.approve_date = DateTime.MinValue;
            ord.old_no       = "";
            ord.cust_cls     = "";

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

            foreach (var item in lines)
            {
                item.branch_no_d = "";
                item.ly_sup_no   = "";
                item.ly_rate     = 0M;
                item.produce_day = DateTime.MinValue;
            }
            string sheet_no = "";

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

            w.Write("sheet_no", sheet_no);
        }
Example #2
0
        void IInOutBLL.ChangeSaleSheet(Model.sm_t_salesheet ord, List <Model.sm_t_salesheet_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 sm_t_salesheet 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"]).ToString("yyyy-MM-dd HH:mm:ss") != ord.update_time.ToString("yyyy-MM-dd HH:mm:ss"))
                    {
                        throw new Exception("单据已被他人修改[" + ord.sheet_no + "]");
                    }
                }
                sql = "delete from sm_t_salesheet_detail where sheet_no='" + ord.sheet_no + "'";
                d.ExecuteScalar(sql, null);
                sql = "delete from sm_t_salesheet where sheet_no='" + ord.sheet_no + "'";
                d.ExecuteScalar(sql, null);
                //
                ord.update_time = DateTime.Now;
                d.Insert(ord);
                foreach (Model.sm_t_salesheet_detail line in lines)
                {
                    sql          = "select isnull(max(flow_id),0) + 1 as flow_id from sm_t_salesheet_detail ";
                    line.flow_id = Helper.Conv.ToInt64(d.ExecuteScalar(sql, null));
                    d.Insert(line);
                }
                //
                db.CommitTran();
            }
            catch (Exception ex)
            {
                LogHelper.writeLog("InOutBLL.ChangeSaleSheet()", ex.ToString(), ord.sheet_no);
                db.RollBackTran();
                throw ex;
            }
            finally
            {
                db.Close();
            }
        }
Example #3
0
        void IInOutBLL.AddSaleSheet(Model.sm_t_salesheet ord, List <Model.sm_t_salesheet_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, "SO");
                ord.sheet_no    = sheet_no;
                ord.create_time = DateTime.Now;
                ord.update_time = ord.create_time;
                //
                d.Insert(ord);

                foreach (Model.sm_t_salesheet_detail line in lines)
                {
                    string sql = "select isnull(max(flow_id),0) + 1 as flow_id from sm_t_salesheet_detail ";
                    line.flow_id  = Helper.Conv.ToInt64(d.ExecuteScalar(sql, null));
                    line.sheet_no = sheet_no;
                    d.Insert(line);
                }
                //
                db.CommitTran();
            }
            catch (Exception ex)
            {
                LogHelper.writeLog("InOutBLL.AddSaleSheet()", ex.ToString(), ord.sheet_no);
                db.RollBackTran();
                throw ex;
            }
            finally
            {
                db.Close();
            }
        }
Example #4
0
        void IBLL.IInOutBLL.AddSaleSheet(Model.sm_t_salesheet ord, List <Model.sm_t_salesheet_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("voucher_no", ord.voucher_no);
            w.Append("cust_no", ord.cust_no);
            w.Append("pay_way", ord.pay_way);
            w.Append("discount", ord.discount.ToString());
            w.Append("coin_no", ord.coin_no);
            w.Append("real_amount", ord.real_amount.ToString());
            w.Append("total_amount", ord.total_amount.ToString());
            w.Append("paid_amount", ord.paid_amount.ToString());
            w.Append("oper_id", ord.oper_id);
            w.Append("sale_man", ord.sale_man);
            w.Append("cm_branch", ord.cm_branch);
            w.Append("oper_date", ord.oper_date.ToString("yyyy-MM-dd HH:mm:ss"));
            w.Append("other1", ord.other1);
            w.Append("other2", ord.other2);
            w.Append("other3", ord.other3);
            w.Append("other4", ord.other4);
            w.Append("old_no", ord.old_no);
            w.Append("psheet_no", ord.psheet_no);
            w.Append("pay_nowmark", ord.pay_nowmark);
            w.Append("payfee_memo", ord.payfee_memo);
            w.Append("num1", ord.num1.ToString());
            w.Append("num2", ord.num2.ToString());
            w.Append("num3", ord.num3.ToString());
            w.Append("if_back", ord.if_back);
            w.Append("pay_date", ord.pay_date.ToString("yyyy-MM-dd HH:mm:ss"));
            w.Append("update_time", ord.update_time.ToString("yyyy-MM-dd HH:mm:ss"));

            var tb = new DataTable();

            tb.Columns.Add("sheet_no");
            tb.Columns.Add("item_no");
            tb.Columns.Add("item_name");
            tb.Columns.Add("unit_no");
            tb.Columns.Add("unit_factor", typeof(decimal));
            tb.Columns.Add("sale_qnty", typeof(decimal));
            tb.Columns.Add("sale_price", typeof(decimal));
            tb.Columns.Add("real_price", typeof(decimal));
            tb.Columns.Add("cost_price", typeof(decimal));
            tb.Columns.Add("sale_money", typeof(decimal));
            tb.Columns.Add("sale_tax", typeof(decimal));
            tb.Columns.Add("is_tax");
            tb.Columns.Add("other1");
            tb.Columns.Add("other2");
            tb.Columns.Add("other3");
            tb.Columns.Add("other4");
            tb.Columns.Add("other5");
            tb.Columns.Add("num1", typeof(decimal));
            tb.Columns.Add("num2", typeof(decimal));
            tb.Columns.Add("num3", typeof(decimal));
            tb.Columns.Add("num4", typeof(decimal));
            tb.Columns.Add("num5", typeof(decimal));
            tb.Columns.Add("num6", typeof(decimal));
            tb.Columns.Add("num7", typeof(decimal));
            tb.Columns.Add("num8", typeof(decimal));
            tb.Columns.Add("barcode");
            tb.Columns.Add("voucher_no");
            tb.Columns.Add("sheet_sort", typeof(int));
            tb.Columns.Add("ret_qnty", typeof(decimal));
            tb.Columns.Add("discount", typeof(decimal));
            tb.Columns.Add("cost_notax", typeof(decimal));
            tb.Columns.Add("packqty", typeof(int));
            tb.Columns.Add("sgqty", typeof(decimal));

            foreach (Model.sm_t_salesheet_detail line in lines)
            {
                tb.Rows.Add(line.sheet_no, line.item_no, line.item_name, line.unit_no, line.unit_factor, line.sale_qnty, line.sale_price,
                            line.real_price, line.cost_price, line.sale_money, line.sale_tax, line.is_tax, line.other1, line.other2, line.other3,
                            line.other4, line.other5, line.num1, line.num2, line.num3, line.num4, line.num5, line.num6, line.num7, line.num8,
                            line.barcode, line.voucher_no, line.sheet_sort, line.ret_qnty, line.discount, line.cost_notax, line.packqty, line.sgqty);
            }
            w.Append("lines", tb);

            Helper.IRequest req = new Helper.Request();


            var json = req.request("/inout?t=add_salesheet", 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");
        }