Пример #1
0
        void IOrder.Save()
        {
            try
            {
                System.Windows.Forms.Cursor.Current = System.Windows.Forms.Cursors.WaitCursor;
                //
                if (txt_sup.Text.Trim().Contains("/") == false)
                {
                    MsgForm.ShowFrom("客户编码必填!");
                    return;
                }
                if (txtbranch.Text.Trim().Contains("/") == false)
                {
                    MsgForm.ShowFrom("机构必填!");
                    return;
                }
                if (txtoper_date.Text.Trim() == "")
                {
                    MsgForm.ShowFrom("单据日期必填!");
                    return;
                }

                co_t_order_main         ord   = new co_t_order_main();
                List <co_t_order_child> lines = new List <co_t_order_child>();
                ord.sheet_no     = txtsheet_no.Text.Trim();
                ord.branch_no    = txtbranch.Text.Trim().Split('/')[0];
                ord.sup_no       = txt_sup.Text.Trim().Split('/')[0];
                ord.coin_code    = lbl_coin_no.Text.Trim();
                ord.paid_amount  = Helper.Conv.ToDecimal(txt_paid_amount.Text);
                ord.oper_date    = Helper.Conv.ToDateTime(txtoper_date.Text.Trim());
                ord.oper_id      = txtoper_man.Text.Split('/')[0];
                ord.order_man    = txt_order_man.Text.Split('/')[0];
                ord.trans_no     = "S";
                ord.order_status = "0";
                ord.sale_way     = "A";
                ord.p_sheet_no   = "";
                ord.approve_flag = "0";
                ord.other1       = "";
                ord.cm_branch    = "00";
                ord.approve_man  = txtapprove_man.Text.Split('/')[0];
                ord.approve_date = System.DateTime.MinValue;
                ord.num1         = 0;
                ord.num2         = 0;
                ord.num3         = 0;
                ord.valid_date   = dtvalid_date.Text.ToDateTime();
                ord.memo         = txtmemo1.Text;
                ord.other2       = txtmemo2.Text;

                int     flag      = 0;
                int     index     = 0;
                decimal total_amt = 0;
                foreach (DataRow row in editGrid1.DataSource.Rows)
                {
                    ++index;
                    if (row["item_no"].ToString() != "")
                    {
                        co_t_order_child line = new co_t_order_child();
                        lines.Add(line);
                        line.sheet_no    = ord.sheet_no;
                        line.item_no     = row["item_no"].ToString();
                        line.unit_no     = row["unit_no"].ToString();
                        line.barcode     = row["barcode"].ToString();
                        line.unit_factor = 1;
                        line.discount    = row["discount"].ToDecimal();
                        line.in_price    = Helper.Conv.ToDecimal(row["in_price"].ToString());
                        line.order_qnty  = Helper.Conv.ToDecimal(row["order_qnty"].ToString());
                        line.sub_amount  = Helper.Conv.ToDecimal(row["sub_amount"].ToString());
                        line.discount    = 1;
                        line.other1      = row["other1"].ToString();
                        line.other2      = "";
                        line.voucher_no  = "";
                        line.sheet_sort  = index;
                        line.num1        = 0;
                        line.num2        = 0;
                        line.num3        = 0;
                        line.packqty     = 0;
                        line.sgqty       = 0;
                        flag             = 1;
                        total_amt       += line.order_qnty * line.in_price;
                    }
                }
                if (flag == 0)
                {
                    MsgForm.ShowFrom("请输入表单明细");
                    return;
                }
                ord.total_amount = total_amt;

                if (runType == 1)
                {
                    IBLL.IInOutBLL bll      = new BLL.InOutBLL();
                    var            sheet_no = "";
                    bll.AddSaleSSSheet(ord, lines, out sheet_no);
                    IOrder ins = this;
                    ins.ShowOrder(sheet_no);
                }
                else if (runType == 2)
                {
                    IBLL.IInOutBLL bll = new BLL.InOutBLL();
                    bll.ChangeSaleSSSheet(ord, lines);
                    IOrder ins = this;
                    ins.ShowOrder(ord.sheet_no);
                }

                Dictionary <string, object> dic = this.Tag as Dictionary <string, object>;
                this.Tag = Helper.Conv.ControlsAdds(this, dic);

                IBLL.ISys sys       = new BLL.SysBLL();
                string    isApprove = sys.Read("approve_at_ones");
                if ("1".Equals(isApprove))
                {
                    if (YesNoForm.ShowFrom("保存成功!是否立即审核") == DialogResult.Yes)
                    {
                        tsbCheck_Click(new object(), new EventArgs());
                    }
                }
            }
            catch (Exception ex)
            {
                Helper.LogHelper.writeLog("frmSaleSheet->Save()", ex.ToString(), txtsheet_no.Text);
                MsgForm.ShowFrom("销售订单保存异常[" + ex.Message + "]");
            }
            finally
            {
                System.Windows.Forms.Cursor.Current = System.Windows.Forms.Cursors.Default;
            }
        }
Пример #2
0
        private void SaveSheet()
        {
            if (curr_cust == null || string.IsNullOrEmpty(curr_cust.supcust_no))
            {
                MsgForm.ShowFrom("请选择客户!");
                return;
            }
            if (sale_detail.Rows.Count < 1)
            {
                MsgForm.ShowFrom("请输入明细!");
                return;
            }

            co_t_order_main         ord   = new co_t_order_main();
            List <co_t_order_child> lines = new List <co_t_order_child>();

            ord.sheet_no     = "";
            ord.trans_no     = "S";
            ord.order_status = "0";
            ord.sale_way     = "A";
            ord.coin_code    = "RMB";
            ord.branch_no    = sale_master.branch_no;
            ord.p_sheet_no   = "";
            ord.sup_no       = sale_master.sup_no;
            ord.paid_amount  = 0;
            ord.oper_date    = sale_master.oper_date;
            ord.oper_id      = Program.oper.oper_id;
            ord.order_man    = "00";
            ord.approve_flag = "0";
            ord.other1       = "";
            ord.other2       = "";
            ord.cm_branch    = "00";
            ord.approve_man  = "";
            ord.approve_date = System.DateTime.MinValue;
            ord.num1         = 0;
            ord.num2         = 0;
            ord.num3         = 0;
            ord.valid_date   = sale_master.oper_date.AddMonths(1);
            ord.memo         = sale_master.memo;

            int     index     = 0;
            decimal total_amt = 0;

            foreach (DataRow row in sale_detail.Rows)
            {
                ++index;
                if (row["item_no"].ToString() != "")
                {
                    co_t_order_child line = new co_t_order_child();
                    lines.Add(line);
                    line.sheet_no    = ord.sheet_no;
                    line.item_no     = row["item_no"].ToString();
                    line.unit_no     = row["unit_no"].ToString();
                    line.barcode     = row["barcode"].ToString();
                    line.unit_factor = 1;
                    line.order_qnty  = Helper.Conv.ToDecimal(row["order_qnty"].ToString());
                    line.in_price    = Helper.Conv.ToDecimal(row["in_price"].ToString());
                    line.real_qty    = 0;
                    line.sub_amount  = Helper.Conv.ToDecimal(row["sub_amount"].ToString());
                    line.sheet_sort  = index;
                    line.discount    = 1;
                    line.other1      = row["other1"].ToString();
                    line.other2      = "";
                    line.other3      = "0";
                    line.voucher_no  = "";
                    line.sheet_sort  = index;
                    line.num1        = 0;
                    line.num2        = 0;
                    line.num3        = 0;
                    line.packqty     = 0;
                    line.sgqty       = 0;

                    total_amt += line.in_price * line.order_qnty;
                }
            }
            ord.total_amount = total_amt;
            ord.paid_amount  = 0;

            string sheet_no;

            IBLL.IInOutBLL bll = new BLL.InOutBLL();
            bll.AddSaleSSSheet(ord, lines, out sheet_no);

            NewSheet();
        }