Пример #1
0
        void Export_Payment()
        {
            try
            {
                c_row_select = dgrContract.SelectedIndex;
                Contract_Info _Contract_Info = (Contract_Info)dgrContract.SelectedItem;

                if (_Contract_Info == null)
                {
                    return;
                }

                List <Fees_Revenue_Info> _lst = _Fees_Revenue_Controller.Fees_Revenue_GetByContract(_Contract_Info.Contract_Id);
                Fees_Revenue_Info        _Fees_Revenue_Info = new Fees_Revenue_Info();

                bool _is_not_pay = false;

                // kiểm tra xem đã thanh toán hết chưa
                foreach (Fees_Revenue_Info item in _lst)
                {
                    if (item.Pay_Status == (decimal)Enum_Fee_Status.No_Pay)
                    {
                        _is_not_pay        = true;
                        _Fees_Revenue_Info = item;
                        break;
                    }
                }

                if (_is_not_pay == false)
                {
                    NoteBox.Show("Đã thanh toán hết, không thể yêu cầu thanh toán", "", NoteBoxLevel.Error);
                    return;
                }

                Estate_Object_Info _Estate_Object_Info = _Estate_Object_Controller.Estate_Object_GetById(_Contract_Info.Estate_Id, (decimal)Enum_Contract_Type.Renter);
                Customer_Info      _Customer_Info      = _Customer_Controller.Customer_GetById(_Contract_Info.Object_Id);

                CommonFunction.Export_payment(_Contract_Info, _Customer_Info, _Estate_Object_Info, _Fees_Revenue_Info);
            }
            catch (Exception ex)
            {
                ErrorLog.log.Error(ex.ToString());
            }
        }
Пример #2
0
        void Export_Payment()
        {
            try
            {
                Fee_Report_Info _Fees_Revenue_Info = (Fee_Report_Info)dgrContract.SelectedItem;

                if (_Fees_Revenue_Info == null)
                {
                    return;
                }
                Customer_Info      _Customer_Info      = _Customer_Controller.Customer_GetById(_Fees_Revenue_Info.Object_Id);
                Estate_Object_Info _Estate_Object_Info = _Estate_Object_Controller.Estate_Object_GetById(_Fees_Revenue_Info.Estate_Id, _Fees_Revenue_Info.Contract_Type);

                #region Kết xuất

                FlexCel.Report.FlexCelReport flcReport = new FlexCel.Report.FlexCelReport();
                string _path          = CommonData.ExcelDesignFilePath;
                string _fileExcelName = "Payment_Request_VND.xls";

                if (_Fees_Revenue_Info.Currency == (decimal)Enum_Contract_Currency.USD)
                {
                    _fileExcelName = "Payment_Request_USD.xls";
                }

                _path += _fileExcelName;

                CommonFunction.SetValueExportByString(ref flcReport, "CurrentDate", DateTime.Now.ToString("dd/MM/yyyy"));
                CommonFunction.SetValueExportByString(ref flcReport, "Tenat_Name", _Customer_Info.Customer_Name);
                CommonFunction.SetValueExportByString(ref flcReport, "Address", _Customer_Info.Address);
                CommonFunction.SetValueExportByString(ref flcReport, "Users", _Fees_Revenue_Info.Users);
                CommonFunction.SetValueExportByString(ref flcReport, "TaxCode", _Customer_Info.Tax_Code);
                CommonFunction.SetValueExportByString(ref flcReport, "Estate_Name", _Estate_Object_Info.Estate_Name);
                CommonFunction.SetValueExportByString(ref flcReport, "Contract_FromDate", _Fees_Revenue_Info.Contract_FromDate.ToString("dd/MM/yyyy"));
                CommonFunction.SetValueExportByString(ref flcReport, "Contract_ToDate", _Fees_Revenue_Info.Contract_ToDate.ToString("dd/MM/yyyy"));

                //decimal _VAT_Fee = Math.Round(_Fees_Revenue_Info.Fee_Expected * 10 / 100);
                //decimal _Fee = _Fees_Revenue_Info.Fee_Expected - _VAT_Fee;

                //decimal _p = 110 / 100;
                //decimal _Fee = _Fees_Revenue_Info.Fee_Expected / _p;
                //decimal _VAT_Fee = Math.Round(_Fee * 10 / 100);
                decimal _Fee     = (_Fees_Revenue_Info.Fee_Expected / 110) * 100;
                decimal _VAT_Fee = Math.Round(_Fee * 10 / 100);

                CommonFunction.SetValueExportByString(ref flcReport, "Fee", _Fee.ToString("###,##0"));
                CommonFunction.SetValueExportByString(ref flcReport, "VAT_Fee", _VAT_Fee.ToString("###,##0"));
                CommonFunction.SetValueExportByString(ref flcReport, "Total_Fee", _Fees_Revenue_Info.Fee_Expected.ToString("###,##0"));

                if (_Fees_Revenue_Info.Contract_Type == (decimal)Enum_Contract_Type.Tenant)
                {
                    #region Kỳ thanh toán
                    string _Kytt = "Thanh toán phí MG lần " + _Fees_Revenue_Info.Number_Payment
                                   + " từ ngày " + _Fees_Revenue_Info.HanChuyenTien.ToString("dd/MM/yyyy") + " đến ngày " +
                                   _Fees_Revenue_Info.HanChuyenTien.AddDays(30).ToString("dd/MM/yyyy");

                    if (_Fees_Revenue_Info.Term == (decimal)Enum_Fee_Maturity.One)
                    {
                        _Kytt = "Thanh toán phí MG lần " + _Fees_Revenue_Info.Number_Payment
                                + " từ ngày " + _Fees_Revenue_Info.HanChuyenTien.ToString("dd/MM/yyyy") + " đến ngày " +
                                _Fees_Revenue_Info.HanChuyenTien.AddDays(30).ToString("dd/MM/yyyy");
                    }
                    else if (_Fees_Revenue_Info.Term == (decimal)Enum_Fee_Maturity.One_Month)
                    {
                        _Kytt = "Thanh toán phí MG lần " + _Fees_Revenue_Info.Number_Payment
                                + " từ ngày " + _Fees_Revenue_Info.HanChuyenTien.ToString("dd/MM/yyyy") + " đến ngày " +
                                _Fees_Revenue_Info.HanChuyenTien.AddMonths(1).ToString("dd/MM/yyyy");
                    }
                    else if (_Fees_Revenue_Info.Term == (decimal)Enum_Fee_Maturity.Three_Month)
                    {
                        _Kytt = "Thanh toán phí MG lần " + _Fees_Revenue_Info.Number_Payment
                                + " từ ngày " + _Fees_Revenue_Info.HanChuyenTien.ToString("dd/MM/yyyy") + " đến ngày " +
                                _Fees_Revenue_Info.HanChuyenTien.AddMonths(3).ToString("dd/MM/yyyy");
                    }
                    else if (_Fees_Revenue_Info.Term == (decimal)Enum_Fee_Maturity.Six_Month)
                    {
                        _Kytt = "Thanh toán phí MG lần " + _Fees_Revenue_Info.Number_Payment
                                + " từ ngày " + _Fees_Revenue_Info.HanChuyenTien.ToString("dd/MM/yyyy") + " đến ngày " +
                                _Fees_Revenue_Info.HanChuyenTien.AddMonths(6).ToString("dd/MM/yyyy");
                    }
                    else if (_Fees_Revenue_Info.Term == (decimal)Enum_Fee_Maturity.One_Year)
                    {
                        _Kytt = "Thanh toán phí MG lần " + _Fees_Revenue_Info.Number_Payment
                                + " từ ngày " + _Fees_Revenue_Info.HanChuyenTien.ToString("dd/MM/yyyy") + " đến ngày " +
                                _Fees_Revenue_Info.HanChuyenTien.AddYears(1).ToString("dd/MM/yyyy");
                    }

                    CommonFunction.SetValueExportByString(ref flcReport, "KyThanhToan", _Kytt);
                    #endregion
                }
                else
                {
                    CommonFunction.SetValueExportByString(ref flcReport, "KyThanhToan", "");
                }

                DateTime _dt_from = DateTime.Now;
                DateTime _dt_To   = _dt_from.AddDays(30);

                CommonFunction.SetValueExportByString(ref flcReport, "From", _dt_from.ToString("dd/MM/yyyy"));
                CommonFunction.SetValueExportByString(ref flcReport, "To", _dt_To.ToString("dd/MM/yyyy"));

                //CommonFunction.SetValueExportByString(ref flcReport, "From", _Fees_Revenue_Info.HanChuyenTien.ToString("dd/MM/yyyy"));
                //CommonFunction.SetValueExportByString(ref flcReport, "To", _Fees_Revenue_Info.HanChuyenTien.AddDays(30).ToString("dd/MM/yyyy"));

                if (_Fees_Revenue_Info.Price != 0)
                {
                    CommonFunction.SetValueExportByString(ref flcReport, "Price", _Fees_Revenue_Info.Price.ToString("###,##0"));
                }
                else
                {
                    CommonFunction.SetValueExportByString(ref flcReport, "Price", "");
                }

                string _tienBangChu = ConvertData.ConvertMoneyToStr(Convert.ToDouble(_Fees_Revenue_Info.Fee_Expected));
                if (_Fees_Revenue_Info.Currency == (decimal)Enum_Contract_Currency.USD)
                {
                    _tienBangChu = c_Contract_Controller.Convert_Dola(_Fees_Revenue_Info.Fee_Expected);
                }

                if (_Fees_Revenue_Info.Currency == (decimal)Enum_Contract_Currency.USD)
                {
                    CommonFunction.SetValueExportByString(ref flcReport, "VND", _Fees_Revenue_Info.Fee_Vnd.ToString("###,##0"));
                }

                CommonFunction.SetValueExportByString(ref flcReport, "BangChu", _tienBangChu.ToLower());

                System.Windows.Forms.SaveFileDialog saveReport = new System.Windows.Forms.SaveFileDialog();
                saveReport.Filter = "Excel files (*.xls)|*.xls";
                if (saveReport.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                {
                    CommonFunction.ExportExcel(flcReport, _path, saveReport);
                }

                #endregion
            }
            catch (Exception ex)
            {
                ErrorLog.log.Error(ex.ToString());
            }
        }
Пример #3
0
        void LoadData()
        {
            try
            {
                List <AllCode_Info> _lst_C_T = DBMemory.AllCode_GetBy_CdNameCdType("CONTRACT", "STATUS");

                cboStatus.ItemsSource       = _lst_C_T;
                cboStatus.DisplayMemberPath = "Content";
                cboStatus.SelectedValuePath = "CdValue";

                List <AllCode_Info> _lst_Currency = DBMemory.AllCode_GetBy_CdNameCdType("CONTRACT", "CURENCY");
                cboCurrency.ItemsSource       = _lst_Currency;
                cboCurrency.DisplayMemberPath = "Content";
                cboCurrency.SelectedValuePath = "CdValue";

                Estate_Object_Info _Estate_Object_Info = _Estate_Object_Controller.Estate_Object_GetById(c_Contract_Info.Estate_Id, (decimal)Enum_Contract_Type.Renter);
                lbl_Estate_Name.Content      = _Estate_Object_Info.Estate_Name;
                lbl_Estate_Code.Content      = _Estate_Object_Info.Estate_Code;
                lbl_Estate_Type_Name.Content = _Estate_Object_Info.Estate_Type_Name;
                lbl_Estate_Area.Content      = _Estate_Object_Info.Area;
                lbl_Address.Content          = _Estate_Object_Info.Address;

                Customer_Info _Customer_Info = c_Customer_Controller.Customer_GetById(c_Contract_Info.Object_Id);
                if (_Customer_Info != null)
                {
                    txtRenter_Name.Text   = _Customer_Info.Customer_Name;
                    txtAddress.Text       = _Customer_Info.Address;
                    txtPhone.Text         = _Customer_Info.Phone;
                    txtFax.Text           = _Customer_Info.Fax;
                    txtRepresentive.Text  = c_Contract_Info.Representive;
                    txtUsers.Text         = c_Contract_Info.Users;
                    txtTaxCode.Text       = _Customer_Info.Tax_Code;
                    txtIdentity_Card.Text = _Customer_Info.Identity_Card;
                }

                txtContract_Code.Text     = c_Contract_Info.Contract_Code;
                txtContract_Name.Text     = c_Contract_Info.Contract_Name;
                dpContractDate.Text       = c_Contract_Info.Contract_Date.ToString("dd/MM/yyyy");
                txtPrice.Text             = c_Contract_Info.Price.ToString("#,##0.#");
                cboCurrency.SelectedValue = c_Contract_Info.Currency;

                #region Fee VND
                if (c_Contract_Info.Currency == (decimal)Enum_Contract_Currency.USD)
                {
                    if (c_Contract_Info.Status == (decimal)Enum_Contract_Status.Gia_Han)
                    {
                        lblThanhTien_Extend.Visibility = Visibility.Visible;
                        txtFee_Vnd_Extend.Visibility   = Visibility.Visible;
                        lblVND_Extend.Visibility       = Visibility.Visible;

                        lblThanhTien.Visibility = Visibility.Collapsed;
                        txtFee_Vnd.Visibility   = Visibility.Collapsed;
                        lblVND.Visibility       = Visibility.Collapsed;
                    }
                    else
                    {
                        lblThanhTien.Visibility = Visibility.Visible;
                        txtFee_Vnd.Visibility   = Visibility.Visible;
                        lblVND.Visibility       = Visibility.Visible;

                        lblThanhTien_Extend.Visibility = Visibility.Collapsed;
                        txtFee_Vnd_Extend.Visibility   = Visibility.Collapsed;
                        lblVND_Extend.Visibility       = Visibility.Collapsed;
                    }
                }
                else
                {
                    lblThanhTien.Visibility = Visibility.Collapsed;
                    txtFee_Vnd.Visibility   = Visibility.Collapsed;
                    lblVND.Visibility       = Visibility.Collapsed;

                    lblThanhTien_Extend.Visibility = Visibility.Collapsed;
                    txtFee_Vnd_Extend.Visibility   = Visibility.Collapsed;
                    lblVND_Extend.Visibility       = Visibility.Collapsed;
                }
                #endregion

                dpFromDate.Text         = c_Contract_Info.Contract_FromDate.ToString("dd/MM/yyyy");
                dpToDate.Text           = c_Contract_Info.Contract_ToDate.ToString("dd/MM/yyyy");
                cboStatus.SelectedValue = c_Contract_Info.Status;

                txtFee.Text = c_Contract_Info.Fee.ToString("#,##0.#");

                List <Fees_Revenue_Info> c_lst_Fee        = new List <Fees_Revenue_Info>();
                List <Fees_Revenue_Info> c_lst_Fee_Extend = new List <Fees_Revenue_Info>();

                if (c_Contract_Info.Status == (decimal)Enum_Contract_Status.Gia_Han)
                {
                    Extend_Contract_Controller  _Extend_Contract_Controller = new Extend_Contract_Controller();
                    List <Extend_Contract_Info> _lst_ex = _Extend_Contract_Controller.Extend_Contract_GetByContractId(c_Contract_Info.Contract_Id);
                    if (_lst_ex.Count > 0)
                    {
                        txtFeeOnePay_Extend.Text = _lst_ex[0].FeeOnePay.ToString("#,##0.#");
                        txtFee_Extend.Text       = _lst_ex[0].Fee.ToString("#,##0.#");
                        dpFromDate_Extend.Text   = _lst_ex[0].Contract_FromDate.ToString("dd/MM/yyyy");
                        dpToDate_Extend.Text     = _lst_ex[0].Contract_ToDate.ToString("dd/MM/yyyy");
                    }

                    tabExtend.Visibility = Visibility.Visible;
                    List <Fees_Revenue_Info> _lst = _Fees_Revenue_Controller.Fees_Revenue_GetByContract(c_Contract_Info.Contract_Id);

                    foreach (Fees_Revenue_Info item in _lst)
                    {
                        if (item.Is_Extend == 1)
                        {
                            c_lst_Fee_Extend.Add(item);
                        }
                        else
                        {
                            c_lst_Fee.Add(item);
                        }
                    }

                    txtFee_Vnd_Extend.Text             = c_lst_Fee_Extend[c_lst_Fee_Extend.Count - 1].Fee_Vnd.ToString("#,##0.#");
                    txtFee_Vnd_Extend.Focusable        = false;
                    txtFee_Vnd_Extend.IsHitTestVisible = false;
                }
                else
                {
                    tabExtend.Visibility = Visibility.Collapsed;
                    c_lst_Fee            = _Fees_Revenue_Controller.Fees_Revenue_GetByContract(c_Contract_Info.Contract_Id);
                    txtFee_Vnd.Text      = c_lst_Fee[c_lst_Fee.Count - 1].Fee_Vnd.ToString("#,##0.#");

                    txtFee_Vnd.Focusable        = false;
                    txtFee_Vnd.IsHitTestVisible = false;
                }

                dgrFee.ItemsSource        = c_lst_Fee;
                dgrFee_Extend.ItemsSource = c_lst_Fee_Extend;
            }
            catch (Exception ex)
            {
                ErrorLog.log.Error(ex.ToString());
            }
        }
Пример #4
0
        void LoadData()
        {
            try
            {
                List <AllCode_Info> _lst_Currency = DBMemory.AllCode_GetBy_CdNameCdType("CONTRACT", "CURENCY");
                cboCurrency.ItemsSource       = _lst_Currency;
                cboCurrency.DisplayMemberPath = "Content";
                cboCurrency.SelectedValuePath = "CdValue";

                List <AllCode_Info> _lst_Term = DBMemory.AllCode_GetBy_CdNameCdType("FEE", "TERM");
                cboTerm.ItemsSource       = _lst_Term;
                cboTerm.DisplayMemberPath = "Content";
                cboTerm.SelectedValuePath = "CdValue";

                cboTerm_Extend.ItemsSource       = _lst_Term;
                cboTerm_Extend.DisplayMemberPath = "Content";
                cboTerm_Extend.SelectedValuePath = "CdValue";

                List <AllCode_Info> _lst_C_T = DBMemory.AllCode_GetBy_CdNameCdType("CONTRACT", "STATUS");

                cboStatus.ItemsSource       = _lst_C_T;
                cboStatus.DisplayMemberPath = "Content";
                cboStatus.SelectedValuePath = "CdValue";

                Estate_Object_Info _Estate_Object_Info = _Estate_Object_Controller.Estate_Object_GetById(c_Contract_Info.Estate_Id, (decimal)Enum_Contract_Type.Tenant);
                if (_Estate_Object_Info != null)
                {
                    lbl_Estate_Name.Content      = _Estate_Object_Info.Estate_Name;
                    lbl_Estate_Code.Content      = _Estate_Object_Info.Estate_Code;
                    lbl_Estate_Type_Name.Content = _Estate_Object_Info.Estate_Type_Name;
                    lbl_Estate_Area.Content      = _Estate_Object_Info.Area;
                    lbl_Address.Content          = _Estate_Object_Info.Address;
                }

                Customer_Info _Customer_Info = c_Customer_Controller.Customer_GetById(c_Contract_Info.Object_Id);
                if (_Customer_Info != null)
                {
                    txtRenter_Name.Text   = _Customer_Info.Customer_Name;
                    txtAddress.Text       = _Customer_Info.Address;
                    txtPhone.Text         = _Customer_Info.Phone;
                    txtFax.Text           = _Customer_Info.Fax;
                    txtPosition.Text      = _Customer_Info.Position;
                    txtTaxCode.Text       = _Customer_Info.Tax_Code;
                    txtIdentity_Card.Text = _Customer_Info.Identity_Card;
                }

                txtRepresentive.Text = c_Contract_Info.Representive;
                txtUsers.Text        = c_Contract_Info.Users;

                txtContract_Code.Text     = c_Contract_Info.Contract_Code;
                dpContractDate.Text       = c_Contract_Info.Contract_Date.ToString("dd/MM/yyyy");
                cboCurrency.SelectedValue = c_Contract_Info.Currency;
                dpFromDate.Text           = c_Contract_Info.Contract_FromDate.ToString("dd/MM/yyyy");
                dpToDate.Text             = c_Contract_Info.Contract_ToDate.ToString("dd/MM/yyyy");
                txtFee.Text             = c_Contract_Info.Fee.ToString("#,##0.#");
                txtPrice.Text           = c_Contract_Info.Price.ToString("#,##0.#");
                cboTerm.SelectedValue   = c_Contract_Info.Term;
                cboStatus.SelectedValue = c_Contract_Info.Status;


                c_max_number_extend = _Extend_Contract_Controller.Get_Number_ExtendContract(c_Contract_Info.Contract_Id);

                List <Extend_Contract_Info> _lst_ex = new List <Extend_Contract_Info>();
                if (c_max_number_extend == 0)
                {
                    tabExtendInfo.Visibility = Visibility.Collapsed;
                }
                else
                {
                    tabExtendInfo.Visibility = Visibility.Visible;
                    _lst_ex = _Extend_Contract_Controller.Extend_Contract_GetByContractId(c_Contract_Info.Contract_Id);

                    dgrExtend.ItemsSource = _lst_ex;
                }

                List <Fees_Revenue_Info> c_lst_Fee        = new List <Fees_Revenue_Info>();
                List <Fees_Revenue_Info> c_lst_Fee_Extend = new List <Fees_Revenue_Info>();

                if (c_Contract_Info.Status == (decimal)Enum_Contract_Status.Gia_Han)
                {
                    if (_lst_ex.Count > 0)
                    {
                        txtFeeOnePay_Extend.Text     = _lst_ex[0].FeeOnePay.ToString("#,##0.#");
                        txtFee_Extend.Text           = _lst_ex[0].Fee.ToString("#,##0.#");
                        dpFromDate_Extend.Text       = _lst_ex[0].Contract_FromDate.ToString("dd/MM/yyyy");
                        dpToDate_Extend.Text         = _lst_ex[0].Contract_ToDate.ToString("dd/MM/yyyy");
                        cboTerm_Extend.SelectedValue = _lst_ex[0].Term;
                    }

                    tabExtend.Visibility = Visibility.Visible;
                    List <Fees_Revenue_Info> _lst = _Fees_Revenue_Controller.Fees_Revenue_GetByContract(c_Contract_Info.Contract_Id);

                    foreach (Fees_Revenue_Info item in _lst)
                    {
                        if (item.Is_Extend == c_max_number_extend)
                        {
                            c_lst_Fee_Extend.Add(item);
                        }
                        else
                        {
                            c_lst_Fee.Add(item);
                        }
                    }
                }
                else
                {
                    tabExtend.Visibility = Visibility.Collapsed;
                    c_lst_Fee            = _Fees_Revenue_Controller.Fees_Revenue_GetByContract(c_Contract_Info.Contract_Id);
                }

                dgrFee.ItemsSource        = c_lst_Fee;
                dgrFee_Extend.ItemsSource = c_lst_Fee_Extend;
            }
            catch (Exception ex)
            {
                ErrorLog.log.Error(ex.ToString());
            }
        }