private void userName_textBox_TextChanged(object sender, EventArgs e)
        {
            try
            {
                CreditHistory creditHistory = new CreditHistory();
                creditHistory.invoiceNo = invoiceNo_TextBox.Text;
                creditHistory.name = clientName_TextBox.Text;
                creditHistory.address = address_TextBox.Text;
                creditHistory.mobileNo = phoneNo_TextBox.Text;
                creditHistory.date = date_TextBox.Text;
                creditHistory.reference = userName_textBox.Text;
                DataSet ds = account_Bo.getCreditHistory(creditHistory);
                clientHistoryMetroGrid.DataSource = ds.Tables[0];
            }
            catch
            {

            }
        }
        private void Home_Admin_CreditHistory_Load(object sender, EventArgs e)
        {
            setFullScreen();
            setMainPanelPosition();
            setRightOptionPanel();
            right_option_timer.Start();

            try
            {
                Account_BO ab = new Account_BO();
                member = ab.getMember(userName);
                memberFirstNameMetroLabel.Text = member.firstName.ToString();
                memberLastNameMetroLabel.Text = member.lastName.ToString();
                MemoryStream ms = new MemoryStream(member.image);
                pictureBox.Image = Image.FromStream(ms);

                CreditHistory creditHistory = new CreditHistory();
                creditHistory.invoiceNo = invoiceNo_TextBox.Text;
                creditHistory.name = clientName_TextBox.Text;
                creditHistory.address = address_TextBox.Text;
                creditHistory.mobileNo = phoneNo_TextBox.Text;
                creditHistory.date = date_TextBox.Text;
                creditHistory.reference = userName_textBox.Text;
                DataSet ds = account_Bo.getCreditHistory(creditHistory);
                clientHistoryMetroGrid.DataSource = ds.Tables[0];

            }
            catch
            {

            }
        }
        private void payment_btn_Click(object sender, EventArgs e)
        {
            try
            {
                if (payAmount_textBox.Text != "" && paymentDue_textBox.Text != "Negetive balance")
                {
                    if (MessageBox.Show("Are you sure?", "Dued Amount Payment", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.Yes)
                    {
                        CreditHistory creditHistory = new CreditHistory();
                        creditHistory.invoiceNo = paymentInvoiceNotextBox.Text;
                        creditHistory.name = paymentClientNametextBox.Text;
                        creditHistory.address = paymentAddresstextBox.Text;
                        creditHistory.mobileNo = paymentPhoneNotextBox.Text;
                        creditHistory.cash = payAmount_textBox.Text;
                        creditHistory.due = paymentDue_textBox.Text;
                        creditHistory.date = dateTimePicker1.Text;
                        creditHistory.reference = userName;
                        account_Bo.setCreditHistory(creditHistory);
                        account_Bo.updateCreditHistoryBalance(creditHistory);
                        MessageBox.Show("Payment successfully done");

                        creditHistory.invoiceNo = paymentInvoiceNotextBox.Text;

                        paymentDue_textBox.Clear();
                        payAmount_textBox.Clear();
                        paymentAddresstextBox.Clear();
                        paymentClientNametextBox.Clear();
                        paymentDue_textBox.Clear();
                        paymentInvoiceNotextBox.Clear();
                        paymentPhoneNotextBox.Clear();
                        lastDuedAmount_textBox.Clear();
                        lastPaidAmount_textBox.Clear();
                        lastPaidDate_textBox.Clear();
                        DataSet ds = account_Bo.getCreditHistory(creditHistory);
                        clientHistoryMetroGrid.DataSource = ds.Tables[0];

                    }
                }
                else
                {
                    MessageBox.Show("Please enter the correct format");
                }
            }
            catch
            {

            }
        }
示例#4
0
 public bool updateCreditHistoryBalance(CreditHistory creditHistory)
 {
     return account_DAL.updateCreditHistoryBalance(creditHistory);
 }
        private void CheckOut_btn_Click(object sender, EventArgs e)
        {
            double invoice =0;
            try
            {

                Member member = account_Bo.getMember(userName);
                if (member.type == "A")
                {
                    if (clientNametextbox.Text != "" && clientMobileNo.Text != "" && clientAddresstextbox.Text != "")
                    {

                        if (nettotalmetroTextBox.Text != "")
                        {
                            if (due_metroTextBox.Text != "Negetive balance")
                            {

                                if (MessageBox.Show("Are you sure?", "Check Out", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.Yes)
                                {
                                    CheckOut_btn.Enabled = false;

                                    try
                                    {
                                        double dis = Convert.ToDouble(discountmetroTextBox.Text);
                                        dis = dis / shoppingCartMetroGrid.Rows.Count;
                                        for (int i = 0; i < shoppingCartMetroGrid.Rows.Count; i++)
                                        {
                                            product.productSerialNo = shoppingCartMetroGrid.Rows[i].Cells[0].Value.ToString();
                                            product.productName = shoppingCartMetroGrid.Rows[i].Cells[1].Value.ToString();
                                            product.productModel = shoppingCartMetroGrid.Rows[i].Cells[2].Value.ToString();
                                            product.productBrand = shoppingCartMetroGrid.Rows[i].Cells[3].Value.ToString();
                                            product.importerInvoiceNo = shoppingCartMetroGrid.Rows[i].Cells[4].Value.ToString();
                                            product.importerID = shoppingCartMetroGrid.Rows[i].Cells[5].Value.ToString();
                                            product.importerName = shoppingCartMetroGrid.Rows[i].Cells[6].Value.ToString();
                                            product.productAvailableWarrenty = shoppingCartMetroGrid.Rows[i].Cells[7].Value.ToString();
                                            product.productShortDescription = shoppingCartMetroGrid.Rows[i].Cells[8].Value.ToString();
                                            product.productLongDescription = shoppingCartMetroGrid.Rows[i].Cells[9].Value.ToString();
                                            product.productEntryDate = shoppingCartMetroGrid.Rows[i].Cells[10].Value.ToString();
                                            product.productBarcode = shoppingCartMetroGrid.Rows[i].Cells[11].Value.ToString();
                                            product.productEntrier = shoppingCartMetroGrid.Rows[i].Cells[12].Value.ToString();
                                            product.productUnitPrice = shoppingCartMetroGrid.Rows[i].Cells[13].Value.ToString();
                                            product.productBatchNo = shoppingCartMetroGrid.Rows[i].Cells[14].Value.ToString();

                                            product.soldDate = firstdateTimePicker.Text;
                                            //dis = dis / 100;
                                            double s = Convert.ToDouble(shoppingCartMetroGrid.Rows[i].Cells[14].Value.ToString());
                                            s = (s - dis);
                                            product.soldPrice = s.ToString();
                                            product.profit = (Convert.ToDouble(s.ToString()) - Convert.ToDouble(shoppingCartMetroGrid.Rows[i].Cells[13].Value.ToString())).ToString();
                                            account_Bo.setSoldProduct(product,userName);

                                            //creditHistorySet

                                            invoice = Convert.ToDouble(account_Bo.getInvoice());
                                            double temp = invoice;
                                            invoice++;

                                            CreditHistory creditHistory = new CreditHistory();
                                            creditHistory.invoiceNo = invoice.ToString();
                                            creditHistory.name = clientNametextbox.Text;
                                            creditHistory.address = clientAddresstextbox.Text;
                                            creditHistory.mobileNo = clientMobileNo.Text;
                                            creditHistory.cash = cash_metroTextBox.Text;
                                            creditHistory.due = due_metroTextBox.Text;
                                            creditHistory.date = productEntryDTP.Text;
                                            creditHistory.reference = userName;
                                            account_Bo.setCreditHistory(creditHistory);
                                            account_Bo.setCreditHistoryBalance(creditHistory);
                                            account_Bo.setInvoice(invoice.ToString(),temp.ToString());
                                        }
                                    }
                                    catch (Exception ex)
                                    {
                                        MessageBox.Show(ex.Message);
                                    }
                                    Home_Admin_PrintBill hp = new Home_Admin_PrintBill();
                                    hp.getTotal(nettotalmetroTextBox.Text, clientNametextbox.Text, clientMobileNo.Text, clientAddresstextbox.Text, discountmetroTextBox.Text, totalmetroTextBox.Text,invoice.ToString(),userName);
                                    hp.Show();
                                    CheckOut_btn.Enabled = true;
                                    totalmetroTextBox.Clear();
                                    returnBarcode_txt.Clear();
                                    soldPrice_txt.Clear();
                                    nettotalmetroTextBox.Clear();
                                    discountmetroTextBox.Clear();
                                    purchasePrice_txt.Clear();
                                    returnSerial_txt.Clear();
                                    due_metroTextBox.Clear();
                                    cash_metroTextBox.Clear();
                                    account_Bo.deleteAllTempProduct();
                                    reloadshoppingCartDataGridview();
                                }
                            }
                            else
                            {
                                MessageBox.Show("Negative balance!! Please enter the amount in correct format");
                            }

                        }
                        else
                        {
                            MessageBox.Show("Please fill the discount text");
                        }
                    }
                    else
                    {
                        MessageBox.Show("Please enter the client details");
                    }

                }
                else
                {
                    if (clientNametextbox.Text != "" && clientMobileNo.Text != "" && clientAddresstextbox.Text != "")
                    {

                        if (nettotalmetroTextBox.Text != "")
                        {
                            if (due_metroTextBox.Text != "Negetive balance")
                            {

                                if (MessageBox.Show("Are you sure?", "Check Out", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.Yes)
                                {
                                    CheckOut_btn.Enabled = false;

                                    try
                                    {
                                        if (discountmetroTextBox.Text == "0" && nettotalmetroTextBox.Text == cash_metroTextBox.Text)
                                        {

                                            double dis = 0;
                                            dis = dis / shoppingCartMetroGrid.Rows.Count;
                                            for (int i = 0; i < shoppingCartMetroGrid.Rows.Count; i++)
                                            {
                                                product.productSerialNo = shoppingCartMetroGrid.Rows[i].Cells[0].Value.ToString();
                                                product.productName = shoppingCartMetroGrid.Rows[i].Cells[1].Value.ToString();
                                                product.productModel = shoppingCartMetroGrid.Rows[i].Cells[2].Value.ToString();
                                                product.productBrand = shoppingCartMetroGrid.Rows[i].Cells[3].Value.ToString();
                                                product.importerInvoiceNo = shoppingCartMetroGrid.Rows[i].Cells[4].Value.ToString();
                                                product.importerID = shoppingCartMetroGrid.Rows[i].Cells[5].Value.ToString();
                                                product.importerName = shoppingCartMetroGrid.Rows[i].Cells[6].Value.ToString();
                                                product.productAvailableWarrenty = shoppingCartMetroGrid.Rows[i].Cells[7].Value.ToString();
                                                product.productShortDescription = shoppingCartMetroGrid.Rows[i].Cells[8].Value.ToString();
                                                product.productLongDescription = shoppingCartMetroGrid.Rows[i].Cells[9].Value.ToString();
                                                product.productEntryDate = shoppingCartMetroGrid.Rows[i].Cells[10].Value.ToString();
                                                product.productBarcode = shoppingCartMetroGrid.Rows[i].Cells[11].Value.ToString();
                                                product.productEntrier = shoppingCartMetroGrid.Rows[i].Cells[12].Value.ToString();
                                                product.productUnitPrice = shoppingCartMetroGrid.Rows[i].Cells[13].Value.ToString();
                                                product.productBatchNo = shoppingCartMetroGrid.Rows[i].Cells[14].Value.ToString();
                                                product.soldDate = firstdateTimePicker.Text;
                                                //dis = dis / 100;
                                                double s = Convert.ToDouble(shoppingCartMetroGrid.Rows[i].Cells[14].Value.ToString());
                                                s = (s - dis);
                                                product.soldPrice = s.ToString();
                                                product.profit = (Convert.ToDouble(s.ToString()) - Convert.ToDouble(shoppingCartMetroGrid.Rows[i].Cells[13].Value.ToString())).ToString();
                                                account_Bo.setSoldProduct(product,userName);

                                                //creditHistorySet

                                                invoice = Convert.ToDouble(account_Bo.getInvoice());
                                                double temp = invoice;
                                                invoice++;

                                                CreditHistory creditHistory = new CreditHistory();
                                                creditHistory.invoiceNo = invoice.ToString();
                                                creditHistory.name = clientNametextbox.Text;
                                                creditHistory.address = clientAddresstextbox.Text;
                                                creditHistory.mobileNo = clientMobileNo.Text;
                                                creditHistory.cash = cash_metroTextBox.Text;
                                                creditHistory.due = due_metroTextBox.Text;
                                                creditHistory.date = productEntryDTP.Text;
                                                creditHistory.reference = userName;
                                                account_Bo.setCreditHistory(creditHistory);
                                                account_Bo.setCreditHistoryBalance(creditHistory);
                                                account_Bo.setInvoice(invoice.ToString(),temp.ToString());

                                                Home_Admin_PrintBill hp = new Home_Admin_PrintBill();
                                                hp.getTotal(nettotalmetroTextBox.Text, clientNametextbox.Text, clientMobileNo.Text, clientAddresstextbox.Text, discountmetroTextBox.Text, totalmetroTextBox.Text, invoice.ToString(),userName);
                                                hp.Show();
                                                CheckOut_btn.Enabled = true;
                                                totalmetroTextBox.Clear();
                                                returnBarcode_txt.Clear();
                                                soldPrice_txt.Clear();
                                                nettotalmetroTextBox.Clear();
                                                discountmetroTextBox.Clear();
                                                purchasePrice_txt.Clear();
                                                returnSerial_txt.Clear();
                                                due_metroTextBox.Clear();
                                                cash_metroTextBox.Clear();
                                                account_Bo.deleteAllTempProduct();
                                                reloadshoppingCartDataGridview();
                                            }
                                        }
                                        else
                                        {
                                            MessageBox.Show("Please fill the discount box with '0' and fill cash with NetTotal amount");
                                            cash_metroTextBox.Clear();
                                            discountmetroTextBox.Clear();
                                            CheckOut_btn.Enabled = true;
                                        }
                                    }
                                    catch (Exception ex)
                                    {
                                        MessageBox.Show(ex.Message);
                                    }

                                }
                            }
                            else
                            {
                                MessageBox.Show("Negative balance!! Please enter the amount in correct format");
                            }

                        }
                        else
                        {
                            MessageBox.Show("Please fill the discount text");
                        }
                    }
                    else
                    {
                        MessageBox.Show("Please enter the client details");
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
示例#6
0
 //creditHistoryBalance
 public bool setCreditHistoryBalance(CreditHistory creditHistory)
 {
     return account_DAL.setCreditHistoryBalance(creditHistory);
 }
示例#7
0
 public DataSet getCreditHistory(CreditHistory creditHistory)
 {
     return account_DAL.getCreditHistory(creditHistory);
 }
示例#8
0
        //CreditHistoryBalance
        public bool setCreditHistoryBalance(CreditHistory creditHistory)
        {
            try
            {
                SqlConnection conn = new SqlConnection(connString);
                SqlCommand cmd = new SqlCommand("SetCreditHistoryBalance", conn);
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.Parameters.Add("@InvoiceNo", SqlDbType.NVarChar, 50).Value = creditHistory.invoiceNo;
                cmd.Parameters.Add("@Due", SqlDbType.NVarChar, 50).Value = creditHistory.due;
                cmd.Parameters.Add("@Date", SqlDbType.NVarChar, 10).Value = creditHistory.date;

                conn.Open();
                cmd.ExecuteNonQuery();
                conn.Close();
                return true;
            }
            catch
            {
                return false;
            }
        }
示例#9
0
        //CreditHistory
        public bool setCreditHistory(CreditHistory creditHistory)
        {
            try
            {
                SqlConnection conn = new SqlConnection(connString);
                SqlCommand cmd = new SqlCommand("SetCreditHistory", conn);
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.Parameters.Add("@InvoiceNo", SqlDbType.NVarChar, 50).Value = creditHistory.invoiceNo;
                cmd.Parameters.Add("@Name", SqlDbType.NVarChar, 50).Value = creditHistory.name;
                cmd.Parameters.Add("@Address", SqlDbType.NVarChar, 200).Value = creditHistory.address;
                cmd.Parameters.Add("@PhoneNo", SqlDbType.NVarChar, 20).Value = creditHistory.mobileNo;
                cmd.Parameters.Add("@Cash", SqlDbType.NVarChar, 50).Value = creditHistory.cash;
                cmd.Parameters.Add("@Due", SqlDbType.NVarChar, 50).Value = creditHistory.due;
                cmd.Parameters.Add("@Date", SqlDbType.NVarChar, 10).Value = creditHistory.date;
                cmd.Parameters.Add("@Reference", SqlDbType.NVarChar, 50).Value = creditHistory.reference;

                conn.Open();
                cmd.ExecuteNonQuery();
                conn.Close();
                return true;
            }
            catch
            {
                return false;
            }
        }
示例#10
0
        public DataSet getCreditHistory(CreditHistory creditHistory)
        {
            try
            {
                SqlConnection conn = new SqlConnection(connString);
                SqlCommand cmd = new SqlCommand("GetCreditHistory2", conn);
                cmd.CommandType = CommandType.StoredProcedure;

                //SqlCommand cmd = new SqlCommand("Select * from CreditHistory where ('" + creditHistory.invoiceNo + "' is null or InvoiceNo like '%" + creditHistory.invoiceNo + "%') and ('" + creditHistory.name + "' is null or Name like '%" + creditHistory.name + "%') and ('" + creditHistory.address + "' is null or Address like '%" + creditHistory.address + "%') and ('" + creditHistory.mobileNo + "' is null or MobileNo like '%" + creditHistory.mobileNo + "%') and ('" + creditHistory.cash + "' is null or Cash like '%" + creditHistory.cash + "%') and ('" + creditHistory.due + "' is null or Due like '%" + creditHistory.due + "%') and ('" + creditHistory.date + "' is null or Date like '%" + creditHistory.date + "%') and ('" + creditHistory.reference + "' is null or Reference like '%" + creditHistory.reference + "%')", conn);
                cmd.Parameters.Add("@InvoiceNo", SqlDbType.NVarChar, 50).Value = creditHistory.invoiceNo;
                cmd.Parameters.Add("@Name", SqlDbType.NVarChar, 50).Value = creditHistory.name;
                cmd.Parameters.Add("@Address", SqlDbType.NVarChar, 200).Value = creditHistory.address;
                cmd.Parameters.Add("@PhoneNo", SqlDbType.NVarChar, 20).Value = creditHistory.mobileNo;
                cmd.Parameters.Add("@Date", SqlDbType.NVarChar, 10).Value = creditHistory.date;
                cmd.Parameters.Add("@Reference", SqlDbType.NVarChar, 50).Value = creditHistory.reference;

                conn.Open();
                //cmd.ExecuteNonQuery();
                DataSet ds = new DataSet();
                SqlDataAdapter sdp = new SqlDataAdapter();
                sdp.SelectCommand = cmd;
                sdp.Fill(ds);
                conn.Close();
                return ds;
            }
            catch(Exception ex)
            {

                return null;
            }
        }