コード例 #1
0
 private void cmb_Shipper_SelectedIndexChanged(object sender, EventArgs e)
 {
     _ShipperId             = (int)cmb_Shipper.SelectedValue;
     shipper                = _shipperBussinessLogic.GetDetailShipper(_ShipperId);
     txtB_ShiperName.Text   = shipper.Name;
     txtB_ShipperEmail.Text = shipper.Email;
     txtB_ShipperPhone.Text = shipper.Phone;
 }
コード例 #2
0
 public bool CreateShipper(ShipperValueObject shipper)
 {
     try
     {
         var listShippers = GetAllShippers();
         if (listShippers.Any(el => el.Email == shipper.Email && el.Phone == shipper.Phone))
         {
             return(false);
         }
         return(_shipperDataAccessLayer.CreateNewShipper(shipper.Name, shipper.Phone, shipper.Email));
     }
     catch (Exception)
     {
         return(false);
     }
 }
コード例 #3
0
        public BillDetailForm(int?BillId = null, int?CusId = null, int?ShipperId = null)
        {
            InitializeComponent();
            _billBusinessLogic            = new BillBusinessLogic();
            _billDetailBusinessLogicLayer = new BillDetailBusinessLogicLayer();
            _shipperBussinessLogic        = new ShipperBussinessLogic();
            _userBusinessLogic            = new UserBusinessLogic();
            _productBusinessLogic         = new ProductBusinessLogic();

            if (BillId == null || CusId == null || ShipperId == null)
            {
                return;
            }
            _BillId    = (int)BillId;
            _CusId     = (int)CusId;
            _ShipperId = (int)ShipperId;

            btn_UpdateNote.Enabled           = false;
            btn_UpdateShipperForBill.Enabled = false;
            rTxtB_Note.Enabled = false;

            bill                 = _billBusinessLogic.GetBillById(_BillId);
            txtB_BillId.Text     = bill.Id.ToString();
            txtB_BillStatus.Text = bill.Status;
            txtB_DateOrder.Text  = bill.DateOrder.ToString();
            txtB_TotalMoney.Text = bill.Total.ToString();
            txtB_Addr.Text       = bill.Addr;
            txtB_Dis.Text        = bill.Dis;
            txtB_city.Text       = bill.City;
            rTxtB_Note.Text      = bill.Note;

            customer          = _userBusinessLogic.GetDetailUser(_CusId);
            txtB_NameCus.Text = customer.Name;

            GridView_BillDetails.DataSource = _billDetailBusinessLogicLayer.GetBillDetailsByBillId(_BillId);


            if (_ShipperId == 0)
            {
                return;
            }

            shipper = _shipperBussinessLogic.GetDetailShipper(_ShipperId);
            txtB_ShiperName.Text   = shipper.Name;
            txtB_ShipperEmail.Text = shipper.Email;
            txtB_ShipperPhone.Text = shipper.Phone;
        }
コード例 #4
0
        private void btn_InsertShipper_Click(object sender, EventArgs e)
        {
            var name  = txtB_NameShipper.Text.Trim();
            var email = txtB_EmailShipper.Text.Trim();
            var phone = txtB_PhoneShipper.Text.Trim();

            if (name == "" || email == "" || phone == "")
            {
                MessageBox.Show("Xin điền đầy đủ thông tin trước khi thực hiện thao tác khác", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            var shipperValueObject = new ShipperValueObject(_isUpdate ? _rowId : 0, name, email, phone);
            var success            = _isUpdate ? _shipperBussinessLogic.UpdateSupplier(shipperValueObject) : _shipperBussinessLogic.CreateShipper(shipperValueObject);

            if (success)
            {
                MessageBox.Show("Cật nhật thành công.", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            else
            {
                MessageBox.Show("Có gì đó không đúng, có thể dữ liệu đã có trong cơ sở dữ liệu", "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
コード例 #5
0
 public bool UpdateSupplier(ShipperValueObject shipper)
 {
     return(_shipperDataAccessLayer.UpdateShipper(shipper.Id, shipper.Name, shipper.Email, shipper.Phone));
 }