Exemplo n.º 1
0
 public static bool AddBill(ref Bill model, out string errMsg)
 {
     return(BillService.AddBill(ref model, out errMsg));
 }
Exemplo n.º 2
0
 public JsonResult Add(Bill bill)
 {
     return(Json(billService.AddBill(bill)));
 }
Exemplo n.º 3
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            if (validator1.Validate() && cbxCustomer.SelectedValue != null && cbxCustomer.SelectedIndex > 0)
            {
                BillService billService = new BillService();
                if (bill == null)
                {
                    double amount    = 0;
                    string amountStr = string.IsNullOrEmpty(txtAmount.WorkingText) ? txtAmount.Text : txtAmount.WorkingText;
                    double.TryParse(amountStr, out amount);
                    DateTime systime = BaoHienRepository.GetBaoHienDBDataContext().GetSystemDate();
                    int      userId  = 0;
                    if (Global.CurrentUser != null)
                    {
                        userId = Global.CurrentUser.Id;
                    }
                    else
                    {
                        MessageBox.Show("Hiện tại hệ thống đang có lỗi. Vui lòng thử lại sau!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        return;
                    }

                    SeedService ss = new SeedService();
                    bill = new Bill
                    {
                        BillCode    = ss.AddSeedID(BHConstant.PREFIX_FOR_BILLING),
                        Note        = txtNote.Text,
                        CreatedDate = systime,
                        Amount      = amount,
                        CustId      = cbxCustomer.SelectedValue != null ? (int)cbxCustomer.SelectedValue : 0,
                        UserId      = userId
                    };

                    bool result            = billService.AddBill(bill);
                    CustomerLogService cls = new CustomerLogService();
                    CustomerLog        cl  = new CustomerLog
                    {
                        CustomerId  = bill.CustId,
                        RecordCode  = bill.BillCode,
                        Amount      = bill.Amount,
                        Direction   = BHConstant.DIRECTION_IN,
                        CreatedDate = systime
                    };
                    result = cls.AddCustomerLog(cl);
                    if (result)
                    {
                        MessageBox.Show("Phiếu thanh toán đã được thêm!");
                    }
                    else
                    {
                        MessageBox.Show("Hiện tại hệ thống đang có lỗi. Vui lòng thử lại sau!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        return;
                    }
                }
                if (this.CallFromUserControll != null && this.CallFromUserControll is BillList)
                {
                    ((BillList)this.CallFromUserControll).loadBillList();
                }
                this.Close();
                return;
            }
            MessageBox.Show("Vui lòng kiểm tra các thông tin cần thiết!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error);
            return;
        }
        private void btnSave_Click(object sender, EventArgs e)
        {
            if (validator1.Validate() && cbxCustomer.SelectedValue != null && cbxCustomer.SelectedIndex > 0)
            {
                BillService billService = new BillService();
                if (bill == null)
                {
                    double amount = 0;
                    string amountStr = string.IsNullOrEmpty(txtAmount.WorkingText) ? txtAmount.Text : txtAmount.WorkingText;
                    double.TryParse(amountStr, out amount);
                    DateTime systime = BaoHienRepository.GetBaoHienDBDataContext().GetSystemDate();
                    int userId = 0;
                    if (Global.CurrentUser != null)
                    {
                        userId = Global.CurrentUser.Id;
                    }
                    else
                    {
                        MessageBox.Show("Hiện tại hệ thống đang có lỗi. Vui lòng thử lại sau!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        return;
                    }
                    
                    SeedService ss = new SeedService();
                    bill = new Bill
                    {
                        BillCode = ss.AddSeedID(BHConstant.PREFIX_FOR_BILLING),
                        Note = txtNote.Text,
                        CreatedDate = systime,
                        Amount = amount,
                        CustId = cbxCustomer.SelectedValue != null ? (int)cbxCustomer.SelectedValue : 0,
                        UserId = userId
                    };

                    bool result = billService.AddBill(bill);
                    CustomerLogService cls = new CustomerLogService();
                    CustomerLog cl = new CustomerLog
                    {
                        CustomerId = bill.CustId,
                        RecordCode = bill.BillCode,
                        Amount = bill.Amount,
                        Direction = BHConstant.DIRECTION_IN,
                        CreatedDate = systime
                    };
                    result = cls.AddCustomerLog(cl);
                    if (result)
                    {
                        MessageBox.Show("Phiếu thanh toán đã được thêm!");
                    }
                    else
                    {
                        MessageBox.Show("Hiện tại hệ thống đang có lỗi. Vui lòng thử lại sau!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        return;
                    }
                }
                if (this.CallFromUserControll != null && this.CallFromUserControll is BillList)
                {
                    ((BillList)this.CallFromUserControll).loadBillList();
                }
                this.Close();
                return;
            }
            MessageBox.Show("Vui lòng kiểm tra các thông tin cần thiết!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error);
            return;  
        }