Beispiel #1
0
        void Search()
        {
            try
            {
                Mouse.OverrideCursor = System.Windows.Input.Cursors.Wait;

                string _name = txtRenterName.Text.ToUpper();
                if (_name == "")
                {
                    _name = CommonData.c_All_Value;
                }

                string _phone = txtPhone.Text.ToUpper();
                if (_phone == "")
                {
                    _phone = CommonData.c_All_Value;
                }

                c_lst = c_Customer_Controller.Customer_Search(_name, _phone);

                Mouse.OverrideCursor  = null;
                dgrRenter.ItemsSource = c_lst;
                DataGridHelper.NVSFocus(dgrRenter, 0, 0);
            }
            catch (Exception ex)
            {
                Mouse.OverrideCursor = null;
                ErrorLog.log.Error(ex.ToString());
            }
        }
        void Accept()
        {
            try
            {
                if (Tenat_CheckValidate() == false)
                {
                    return;
                }

                MessageBoxResult result = NoteBox.Show("Bạn có muốn thêm hợp đồng này hay không?", "Thông báo", NoteBoxLevel.Question);
                if (MessageBoxResult.Yes != result)
                {
                    return;
                }

                #region Thêm mới khách hàng
                Customer_Info _Customer_Info = Get_Customer_Info();
                if (_Customer_Info == null)
                {
                    NoteBox.Show("Lỗi khởi tạo khách cho thuê nhà", "", NoteBoxLevel.Error);
                    return;
                }
                decimal _customer_id = -1;

                // kiểm tra xem thằng tên khách hàng đó và số đt đó đã có trong db chưa
                // nếu có rồi thì ko insert nữa
                string _name = txtRenter_Name.Text.ToUpper();
                if (_name == "")
                {
                    _name = CommonData.c_All_Value;
                }

                string _phone = txtPhone.Text.ToUpper();
                if (_phone == "")
                {
                    _phone = CommonData.c_All_Value;
                }

                List <Customer_Info> _lst = c_Customer_Controller.Customer_Search(_name, _phone);

                if (_lst.Count > 0)
                {
                    // có rồi thì sử dụng luôn
                    // update ngược thông tin lại
                    if (c_Customer_Controller.Customer_Update(_lst[0].Customer_Id, _Customer_Info) == false)
                    {
                        NoteBox.Show("Lỗi cập nhật mới khách thuê nhà", "", NoteBoxLevel.Error);
                        return;
                    }

                    _customer_id = _lst[0].Customer_Id;
                }
                else
                {
                    // không có thì thêm mới
                    _customer_id = c_Customer_Controller.Customer_Insert(_Customer_Info);
                    if (_customer_id == -1)
                    {
                        NoteBox.Show("Lỗi thêm mới khách thuê nhà", "", NoteBoxLevel.Error);
                        return;
                    }
                }

                #endregion

                #region Hợp đồng
                Contract_Info _Contract_Info = Get_Contract_Info(_customer_id);
                if (_Contract_Info == null)
                {
                    NoteBox.Show("Lỗi khởi tạo hợp đồng thuê nhà", "", NoteBoxLevel.Error);
                    return;
                }

                decimal _contract_id = _Contract_Controller.Contract_Insert(_Contract_Info);
                if (_contract_id == -1)
                {
                    NoteBox.Show("Lỗi thêm mới hợp đồng cho thuê nhà", "", NoteBoxLevel.Error);
                    c_Customer_Controller.Customer_Delete(_customer_id);
                    return;
                }

                #endregion

                #region Phí môi giới
                foreach (Fees_Revenue_Info _Fees_Revenue_Info in c_lst_Fee)
                {
                    _Fees_Revenue_Info.Contract_Id  = _contract_id;
                    _Fees_Revenue_Info.Object_Id    = _customer_id;
                    _Fees_Revenue_Info.Object_Type  = (decimal)Enum_Contract_Type.Tenant;
                    _Fees_Revenue_Info.Currency     = Convert.ToDecimal(cboCurrency.SelectedValue);
                    _Fees_Revenue_Info.Fee          = 0;
                    _Fees_Revenue_Info.Debit_Amount = _Fees_Revenue_Info.Fee_Expected - _Fees_Revenue_Info.Fee;
                    _Fees_Revenue_Info.Is_Extend    = 0;
                    _Fees_Revenue_Info.Fee_Vnd      = 0;

                    if (_Fees_Revenue_Info.Fee != 0)
                    {
                        _Fees_Revenue_Info.Pay_Status = (decimal)Enum_Fee_Status.Payed;
                    }

                    if (_Fees_Revenue_Controller.Fees_Revenue_Insert(_Fees_Revenue_Info) == false)
                    {
                        NoteBox.Show("Lỗi thanh toán", "", NoteBoxLevel.Error);
                        c_Customer_Controller.Customer_Delete(_customer_id);
                        _Contract_Controller.Contract_Delete(_contract_id);
                        _Fees_Revenue_Controller.Fees_Revenue_DeleteByContract(_contract_id);
                        return;
                    }
                }
                #endregion

                c_id_insert = _contract_id;

                NoteBox.Show("Thêm mới dữ liệu thành công", "");
                this.Close();
            }
            catch (Exception ex)
            {
                ErrorLog.log.Error(ex.ToString());
            }
        }
Beispiel #3
0
        void Accept()
        {
            try
            {
                if (Customer_CheckValidate() == false)
                {
                    return;
                }

                MessageBoxResult result = NoteBox.Show("Bạn có muốn thêm khách hàng này hay không?", "Thông báo", NoteBoxLevel.Question);
                if (MessageBoxResult.Yes != result)
                {
                    return;
                }

                #region Thêm mới khách hàng
                Customer_Info _Customer_Info = Get_Customer_Info();
                if (_Customer_Info == null)
                {
                    NoteBox.Show("Lỗi khởi tạo khách thuê nhà", "", NoteBoxLevel.Error);
                    return;
                }
                decimal _customer_id = -1;

                // kiểm tra xem thằng tên khách hàng đó và số đt đó đã có trong db chưa
                // nếu có rồi thì ko insert nữa

                string _name = txtCustomer_Name.Text.ToUpper();
                if (_name == "")
                {
                    _name = CommonData.c_All_Value;
                }

                string _phone = txtPhone.Text.ToUpper();
                if (_phone == "")
                {
                    _phone = CommonData.c_All_Value;
                }

                List <Customer_Info> _lst = c_Customer_Controller.Customer_Search(_name, _phone);

                if (_lst.Count > 0)
                {
                    NoteBox.Show("Đã tồn tại khách hàng", "", NoteBoxLevel.Error);
                    return;
                }
                else
                {
                    // không có thì thêm mới
                    _customer_id = c_Customer_Controller.Customer_Insert(_Customer_Info);

                    if (_customer_id == -1)
                    {
                        NoteBox.Show("Lỗi thêm mới khách thuê nhà", "", NoteBoxLevel.Error);
                        return;
                    }
                }

                #endregion

                c_id_insert = _customer_id;
                NoteBox.Show("Thêm mới dữ liệu thành công", "");

                this.Close();
            }
            catch (Exception ex)
            {
                ErrorLog.log.Error(ex.ToString());
            }
        }