public int InsertPassbook(Passbook thePassbook, PassbookPrint thePassbookPrint)
        {
            int ReturnValue = 0;

            using (SqlCommand InsertCommand = new SqlCommand())
            {
                InsertCommand.CommandType = CommandType.StoredProcedure;
                InsertCommand.Parameters.Add(GetParameter("@ReturnValue", SqlDbType.Int, ReturnValue)).Direction = ParameterDirection.Output;
                InsertCommand.Parameters.Add(GetParameter("@PassbookType", SqlDbType.VarChar, thePassbook.PassBookType));
                InsertCommand.Parameters.Add(GetParameter("@PassbookTypeReferenceID", SqlDbType.Int, thePassbook.CustomerAccountID));
                InsertCommand.Parameters.Add(GetParameter("@PassbookIssueDate", SqlDbType.VarChar, thePassbook.PassbookIssueDate));
                InsertCommand.Parameters.Add(GetParameter("@CoverPageState", SqlDbType.Bit, thePassbook.CoverPageState));
                InsertCommand.Parameters.Add(GetParameter("@FirstPageState", SqlDbType.Bit, thePassbook.FirstPageState));
                InsertCommand.Parameters.Add(GetParameter("@PrintPosition", SqlDbType.Int, thePassbook.PrintPosition));
                InsertCommand.Parameters.Add(GetParameter("@PassbookPage", SqlDbType.VarChar, thePassbookPrint.PassbookPage));
                InsertCommand.Parameters.Add(GetParameter("@OfficeID", SqlDbType.Int, Micro.Commons.Connection.LoggedOnUser.OfficeID));
                InsertCommand.Parameters.Add(GetParameter("@AddedBy", SqlDbType.Int, Micro.Commons.Connection.LoggedOnUser.UserID));
                InsertCommand.CommandText = "pCRM_Passbooks_Insert";

                ExecuteStoredProcedure(InsertCommand);

                ReturnValue = int.Parse(InsertCommand.Parameters[0].Value.ToString());

                return(ReturnValue);
            }
        }        //TODO :Requriad  @PassbookIssueDate
示例#2
0
        public Passbook GetAccount(int ID)
        {
            string   query = string.Format("select * from dbo.passbook where id = {0}", ID);
            DataRow  row   = DataProvider.Instance.ExcuteQuery(query).Rows[0];
            Passbook acc   = new Passbook(row);

            return(acc);
        }
示例#3
0
        public static Passbook GetPassbookByTypeReferenceID(string passbookType, int passbookTypeReferenceID)
        {
            DataRow  PassbookRow = PassbookDataAccess.GetInstance.GetPassbookByTypeReferenceID(passbookType, passbookTypeReferenceID);
            Passbook ThePassbook = new Passbook();

            if (PassbookRow != null)
            {
                ThePassbook = DataRowToObject(PassbookRow);
            }

            return(ThePassbook);
        }
示例#4
0
        public static Passbook GetPassbooksByCustomerAccountID(int CustomerAccountID)
        {
            DataRow  PassbookRow = PassbookDataAccess.GetInstance.GetPassbooksByCustomerAccountID(CustomerAccountID);
            Passbook ThePassbook = new Passbook();

            if (PassbookRow != null)
            {
                ThePassbook = DataRowToObject(PassbookRow);
            }

            return(ThePassbook);
        }
        private void View_Transaction(object sender, RoutedEventArgs e)
        {
            string idBill = this.Textbox_Search.Text;

            if (CollectBillDAO.Instance.CheckIfExistBillID(idBill) == true)
            {
                IsWithdrawBill = false;
                CollectBill bill         = CollectBillDAO.Instance.GetBill(idBill);
                Passbook    passbook     = PassbookDAO.Instance.GetAccount(bill.Collect_passbook);
                Customer    customerInfo = CustomerDAO.Instance.GetCustomer(passbook.Passbook_customer);
                //update form
                this.TextBox_CustomerID.Text      = customerInfo.Id.ToString();
                this.TextBox_CustomerIDcard.Text  = customerInfo.Cmnd.ToString();
                this.TextBox_CustomerName.Text    = customerInfo.Cus_name.ToString();
                this.TextBox_CustomerAddress.Text = customerInfo.Cus_address.ToString();
                this.TextBox_SavingBookID.Text    = passbook.Id.ToString();
                this.TextBox_Money.Text           = bill.Collect_money.ToString();
                this.Calender.SelectedDate        = bill.Collectdate;
                this.Combobox_Type.Items.Clear();
                this.Combobox_Type.Items.Add(TypePassbookDAO.Instance.GetTypeNameByID(passbook.Passbooktype));
                this.Combobox_Type.SelectedIndex = 0;

                HintAssist.SetHint(this.TextBox_Money, "Số tiền gởi");
            }
            else if (WithdrawBillDAO.Instance.CheckIfExistBillID(idBill) == true)
            {
                IsWithdrawBill = true;
                WithdrawBill bill         = WithdrawBillDAO.Instance.GetBill(idBill);
                Passbook     passbook     = PassbookDAO.Instance.GetAccount(bill.Withdraw_passbook);
                Customer     customerInfo = CustomerDAO.Instance.GetCustomer(passbook.Passbook_customer);
                //update form
                this.TextBox_CustomerID.Text      = customerInfo.Id.ToString();
                this.TextBox_CustomerIDcard.Text  = customerInfo.Cmnd.ToString();
                this.TextBox_CustomerName.Text    = customerInfo.Cus_name.ToString();
                this.TextBox_CustomerAddress.Text = customerInfo.Cus_address.ToString();
                this.TextBox_SavingBookID.Text    = passbook.Id.ToString();
                this.TextBox_Money.Text           = bill.Withdrawmoney.ToString();
                this.Calender.SelectedDate        = bill.Withdrawdate;
                this.Combobox_Type.Items.Clear();
                this.Combobox_Type.Items.Add(TypePassbookDAO.Instance.GetTypeNameByID(passbook.Passbooktype));
                this.Combobox_Type.SelectedIndex = 0;

                HintAssist.SetHint(this.TextBox_Money, "Số tiền rút");
            }
            else
            {
                MessageBoxCustom.setContent("Không tìm thấy mã giao dịch này.").ShowDialog();
            }
            #endregion
        }
示例#6
0
        public static Passbook DataRowToObject(DataRow dr)
        {
            Passbook ThePassbook = new Passbook();

            ThePassbook.PassbookID              = int.Parse(dr["PassbookID"].ToString());
            ThePassbook.PassbookCode            = dr["PassbookCode"].ToString();
            ThePassbook.PassBookType            = dr["PassBookType"].ToString();
            ThePassbook.PassbookTypeReferenceID = int.Parse(dr["PassbookTypeReferenceID"].ToString());
            //ThePassbook.PrintPosition = int.Parse(dr["PassbookTypeReferenceID"].ToString());
            //ThePassbook.CustomerAccountID = int.Parse(dr["CustomerAccountID"].ToString());
            ThePassbook.CustomerAccountCode = dr["CustomerAccountCode"].ToString();
            ThePassbook.CustomerName        = dr["CustomerName"].ToString();
            ThePassbook.PassbookIssueDate   = dr["PassbookIssueDate"].ToString();
            ThePassbook.CoverPageState      = bool.Parse(dr["CoverPageState"].ToString());
            ThePassbook.FirstPageState      = bool.Parse(dr["FirstPageState"].ToString());
            ThePassbook.PrintPosition       = int.Parse(dr["PrintPosition"].ToString());

            return(ThePassbook);
        }
示例#7
0
        public void InsertPassbook(Passbook passbook)
        {
            int      type     = passbook.Passbooktype;
            long     balance  = passbook.Passbook_balance;
            int      cusid    = passbook.Passbook_customer;
            DateTime?opendate = passbook.Opendate;

            if (opendate != null)
            {
                string query = string.Format("exec usp_InsertPassbook {0} , {1} , {2} , '{3}' ", type, balance, cusid, opendate.Value.ToString("yyyy/MM/dd"));
                DataProvider.Instance.ExcuteNonQuery(query);
            }
            else
            {
                DataProvider.Instance.ExcuteNonQuery("usp_InsertPassbook1 @type , @balance , @cusid", new object[] { type, balance, cusid });
            }

            //opendate,type,balance,customer
        }
示例#8
0
 public static int InsertPassbook(Passbook thePassbook, PassbookPrint thePassbookPrint)
 {
     return(PassbookDataAccess.GetInstance.InsertPassbook(thePassbook, thePassbookPrint));
 }
 public int InsertPassbook(Passbook thePassbook, PassbookPrint thePassbookPrint)
 {
     return(PassbookIntegration.InsertPassbook(thePassbook, thePassbookPrint));
 }
        //check if the customer has had an account type before, if not, create new passbook, if yes, show messagebox warning
        private void Button_OpenPassbook(object sender, RoutedEventArgs e)
        {
            int      IDcustomer = int.Parse(this.TextBox_CustomerID.Text);
            Customer customer   = new Customer
            {
                Cus_address = TextBox_Address.Text.Trim(),
                Cus_name    = TextBox_CustomerName.Text.Trim(),
                Cmnd        = TextBox_CardID.Text.Trim()
            };

            if (this.RadioButton_NewCustomer.IsChecked == true)
            {
                if (string.IsNullOrEmpty(customer.Cus_name) || string.IsNullOrEmpty(customer.Cmnd))
                {
                    MessageBoxCustom.setContent("Chưa điền đầy đủ thông tin khách hàng");
                    return;
                }
                if (PassbookDAO.Instance.CheckBalance(long.Parse(this.TextBox_Money.Text.ToString()), (this.Combobox_TypePassbook.SelectedItem as TypePassbook).Typename))
                {
                    MessageBoxCustom.setContent("Số tiền gởi ban đầu không hợp lệ ").ShowDialog();
                    Clearall();
                    this.TextBox_CustomerID.Text = (CustomerDAO.Instance.GetCurrentMaxCustomerID() + 1).ToString();
                    return;
                }
                CustomerDAO.Instance.InsertCustomer(customer);
            }
            int? idType = (this.Combobox_TypePassbook.SelectedItem as TypePassbook).Id;
            bool Check  = CustomerDAO.Instance.CheckCustomerHasAccountType(IDcustomer, idType);

            if (!Check) //cus dont have any active passbook of this kind
            {
                if (idType != null)
                {
                    Passbook pass = new Passbook
                    {
                        Passbook_customer = IDcustomer,
                        Opendate          = this.DatePicker_DateOpen.SelectedDate ?? DateTime.Now,
                        Passbooktype      = idType ?? -1,
                        Passbook_balance  = 0
                    };
                    PassbookDAO.Instance.InsertPassbook(pass);
                    CollectBill bill = new CollectBill
                    {
                        Id = 1.ToString(),
                        Collect_passbook = int.Parse(this.TextBox_PassbookID.Text.ToString()),
                        Collect_money    = long.Parse(this.TextBox_Money.Text.ToString()),
                        Collectdate      = this.DatePicker_DateOpen.SelectedDate ?? DateTime.Now
                    };
                    CollectBillDAO.Instance.InsertCollectBill(bill);
                    MessageBoxCustom.setContent("Thêm sổ thành công").ShowDialog();
                    Clearall();
                    this.TextBox_PassbookID.Text = (PassbookDAO.Instance.GetMaxID() + 1).ToString();
                    this.TextBox_Money.Clear();
                    if (this.RadioButton_NewCustomer.IsChecked == true)
                    {
                        this.TextBox_CustomerID.Text = (CustomerDAO.Instance.GetCurrentMaxCustomerID() + 1).ToString();
                    }
                }
            }
            else
            {
                MessageBoxCustom.setContent("Lỗi, khách hàng này đã có tài khoản thuộc loại " + (this.Combobox_TypePassbook.SelectedItem as TypePassbook).Typename + " còn thời hạn.").ShowDialog();
            }
        }