예제 #1
0
        private void btnADD_Click(object sender, EventArgs e)
        {
            c.title       = txtTitle.Text;
            c.description = txtDescription.Text;
            c.added_date  = DateTime.Now;

            string  loggedUser = frmLogin.loggedIn;
            userBLL user       = udal.GetIdFromUsername(loggedUser);

            c.added_by = user.id;

            bool success = dal.Insert(c);

            if (success == true)
            {
                MessageBox.Show("New Category INSERT Successfully");
                Clear();
                DataTable dt = dal.Select();
                dgvCategories.DataSource = dt;
            }
            else
            {
                MessageBox.Show("Failed to INSERT new Category");
            }
        }
예제 #2
0
        private void btnAdd_Click(object sender, EventArgs e)
        {
            c.title       = txtTitle.Text;
            c.discription = txtDescription.Text;
            c.added_date  = DateTime.Now;
            string  loggedUser = frmLogin.loggedIn;
            userBLL usr        = udal.GetIdFromUsername(loggedUser);

            c.added_by = usr.Id;

            bool succes = dal.Insert(c);

            if (succes == true)
            {
                MassageBox mb = new MassageBox("Added Success", MsgType.success);
                mb.Show();
                //MessageBox.Show("New Categoty Inserted Succesfully");
                Clear();
                DataTable dt = dal.Select();
                dgvCategories.DataSource = dt;
            }
            else
            {
                MassageBox mb = new MassageBox("Added Failed", MsgType.retry);
                mb.Show();
                //MessageBox.Show("Failed To Insert New Catogory!!!...Try Again");
            }
        }
예제 #3
0
        private void btnAdd_Click(object sender, EventArgs e)
        {
            dc.type       = cmbDeaCust.Text;
            dc.name       = txtName.Text;
            dc.email      = txtEmail.Text;
            dc.contact    = txtContact.Text;
            dc.address    = txtAddress.Text;
            dc.added_date = DateTime.Now;

            string  loggedUser = frmLogin.loggedIn;
            userBLL user       = uDal.GetIdFromUsername(loggedUser);

            dc.added_by = user.id;

            bool success = dcDal.Insert(dc);

            if (success == true)
            {
                MessageBox.Show("Added Successfully");
                Clear();

                DataTable dt = dcDal.Select();
                dgvDeaCust.DataSource = dt;
            }
            else
            {
                MessageBox.Show("Failed to Added");
            }
        }
예제 #4
0
        private void btnAdd_Click(object sender, EventArgs e)
        {
            p.name        = txtName.Text;
            p.category    = cmbCategory.Text;
            p.description = txtDescription.Text;
            p.rate        = Decimal.Parse(txtRate.Text);
            p.qty         = Decimal.Parse(txtQty.Text);
            p.added_date  = DateTime.Now;

            string  loggedUser = frmLogin.loggedIn;
            userBLL user       = udal.GetIdFromUsername(loggedUser);

            p.added_by = user.id;

            bool success = pdal.Insert(p);

            if (success == true)
            {
                MessageBox.Show("New Product Added Successfully");
                Clear();

                DataTable dt = pdal.Select();
                dgvProducts.DataSource = dt;
            }
            else
            {
                MessageBox.Show("Failed to Add New Product");
            }
        }
예제 #5
0
        private void btnAdd_Click(object sender, EventArgs e)
        {
            dc.type       = cmbDlrCust.Text;
            dc.name       = txtName.Text;
            dc.email      = txtEmail.Text;
            dc.contact    = txtContact.Text;
            dc.address    = txtAddress.Text;
            dc.added_date = DateTime.Now;
            string  loggedUsr = frmLogin.loggedIn;
            userBLL usr       = uDal.GetIdFromUsername(loggedUsr);

            dc.added_by = usr.Id;

            bool success = dcdal.Insert(dc);

            if (success == true)
            {
                MassageBox mb = new MassageBox("Added Success", MsgType.success);
                mb.Show();
                //MessageBox.Show("Dealer/Customer Added Successfully...");
                Clear();

                DataTable dt = dcdal.Select();
                dgvDlr_Customer.DataSource = dt;
            }
            else
            {
                MassageBox mb = new MassageBox("Added Failed", MsgType.retry);
                mb.Show();
                //MessageBox.Show("Failed to ADD Dealer/Customer...!!! Try Again..");
            }
        }
        private void btnAdd_Click(object sender, EventArgs e)
        {
            p.name        = txtName.Text;
            p.category    = cmbCategory.Text;
            p.description = txtDescription.Text;
            p.rate        = decimal.Parse(txtRate.Text);
            p.qty         = 0;
            p.added_date  = DateTime.Now;
            string  loggedUsr = frmLogin.loggedIn;
            userBLL usr       = udal.GetIdFromUsername(loggedUsr);

            p.added_by = usr.Id;

            bool success = pdal.Insert(p);

            if (success == true)
            {
                MassageBox mb = new MassageBox("Added Success", MsgType.success);
                mb.Show();
                //MessageBox.Show("Product Added Successfully...");
                Clear();
                DataTable dt = pdal.Select();
                dgvProducts.DataSource = dt;
            }
            else
            {
                MassageBox mb = new MassageBox("Added Failed", MsgType.retry);
                mb.Show();
                //MessageBox.Show("Failed To Added Product!!!...Try again...");
            }
        }
예제 #7
0
        private void btnAdd_Click(object sender, EventArgs e)
        {
            u.first_name = txtFirstName.Text;
            u.last_name  = txtLastName.Text;
            u.email      = txtEmail.Text;
            u.username   = txtUsername.Text;
            u.password   = txtPassword.Text;
            u.contact    = txtContact.Text;
            u.address    = txtAddress.Text;
            u.gender     = cmbGender.Text;
            u.user_type  = cmbUserType.Text;
            u.added_date = DateTime.Now;

            string  loggedUser = frmLogin.loggedIn;
            userBLL usr        = dal.GetIdFromUsername(loggedUser);

            u.added_by = usr.id;

            bool      success = dal.Insert(u);
            DataTable dt      = dal.select();

            dgvUsers.DataSource = dt;
            if (success == true)
            {
                clear();
                MessageBox.Show("New User Created Successfully");
            }
            else
            {
                MessageBox.Show("Failed To Create User");
            }
            // DataTable dt = dal.select();
            //dgvUsers.DataSource = dt;
        }
예제 #8
0
        private void button2_Click(object sender, EventArgs e)
        {
            c.id          = int.Parse(textBox1.Text);
            c.title       = textBox2.Text;
            c.description = textBox3.Text;
            c.added_date  = DateTime.Now;
            string  loggedUser = frmLogin.loggedIn;
            string  loggeduser = frmLogin.loggedIn;
            userDAL udal       = new userDAL();
            userBLL usr        = udal.GetIdFromUsername(loggeduser);

            c.added_by = usr.id;
            bool success = dal.Update(c);

            if (success == true)
            {
                MessageBox.Show("Cetegory Updated Succesfully ...");
                Clear();
                DataTable dt = dal.Select();
                dgvCategories.DataSource = dt;
            }
            else
            {
                MessageBox.Show("Update Failed :/  ");
            }
        }
예제 #9
0
        private void btnAdd_Click(object sender, EventArgs e)
        {
            u.first_name = txtFirstName.Text;
            u.last_name  = txtLastName.Text;
            u.email      = txtEmail.Text;
            u.username   = txtUserName.Text;
            u.password   = txtPassword.Text;
            u.contact    = txtContact.Text;
            u.address    = txtAddress.Text;
            u.gender     = comboGender.Text;
            u.user_type  = comboUserType.Text;
            u.added_date = DateTime.Now;
            string  loggedUser = frmLogin.loggedIn;
            userBLL usr        = dal.GetIdFromUsername(loggedUser);

            u.added_by = loggedUser;
            if (u.user_type == "")
            {
                MassageBox mb = new MassageBox("Added Failed", MsgType.retry);
                mb.Show();
            }
            else
            {
                bool success = dal.Insert(u);

                if (success == true)
                {
                    MassageBox mb = new MassageBox("Added Success", MsgType.success);
                    mb.Show();
                    //MessageBox.Show("User Added Successfully!!!");
                    clear();
                }
                else
                {
                    MassageBox mb = new MassageBox("Added Failed", MsgType.retry);
                    mb.Show();
                    //MessageBox.Show("Fail to Added!!!");
                }
            }

            DataTable dt = dal.Select();

            dgvUser.DataSource = dt;
        }
        private void button1_Click(object sender, EventArgs e)
        {
            // Getting userID
            //update
            string loggedUser = frmLogin.loggedIn;

            // Geting data from UI
            u.first_name = textBox1.Text;
            u.last_name  = textBox2.Text;
            u.email      = textBox3.Text;
            u.username   = textBox4.Text;
            u.password   = textBox5.Text;
            u.contact    = textBox6.Text;
            u.address    = textBox7.Text;
            u.gender     = comboBox1.Text;
            u.user_type  = comboBox2.Text;
            u.added_date = DateTime.Now;

            // String loggedUser = frmLogin.loggedIn;
            userBLL usr = dal.GetIdFromUsername(loggedUser);

            u.added_by = usr.id;

            //Inserting data into database
            bool success = dal.Insert(u);

            if (success == true)
            {
                //data inserted sucesfully
                MessageBox.Show("User Added Succesfully");
                clear();
            }
            else
            {
                //error occured
                MessageBox.Show("Sorry..!! , Failed to add user");
            }
            DataTable dt = dal.Select();

            dgvUsers.DataSource = dt;
        }
        private void btnSave_Click(object sender, EventArgs e)
        {
            try
            {
                transactionsBLL transaction = new transactionsBLL();
                transaction.type = lblTop.Text;
                string deaCustName = txtName.Text;

                DeaCustBLL dc = dcDAL.GetDeaCustIdFromName(deaCustName);
                transaction.dea_cust_id      = dc.Id;
                transaction.grandTotal       = Math.Round(decimal.Parse(txtGrandTotal.Text), 2);
                transaction.transaction_date = DateTime.Now;
                transaction.tax      = decimal.Parse(txtVat.Text);
                transaction.discount = decimal.Parse(txtDiscount.Text);

                string  username = frmLogin.loggedIn;
                userBLL u        = uDAL.GetIdFromUsername(username);

                transaction.added_by           = u.Id;
                transaction.transactionDetails = transactionDT;

                bool success = false;
                using (TransactionScope scope = new TransactionScope())
                {
                    int  transactionId = -1;
                    bool w             = tDAL.Insert_Transaction(transaction, out transactionId);

                    for (int i = 0; i < transactionDT.Rows.Count; i++)
                    {
                        transactionDetailBLL transactionDetail = new transactionDetailBLL();
                        string      productName = transactionDT.Rows[i][0].ToString();
                        productsBLL p           = pdal.GetProductIdFromName(productName);
                        transactionDetail.product_id  = p.Id;
                        transactionDetail.rate        = decimal.Parse(transactionDT.Rows[i][1].ToString());
                        transactionDetail.qty         = decimal.Parse(transactionDT.Rows[i][2].ToString());
                        transactionDetail.total       = Math.Round(decimal.Parse(transactionDT.Rows[i][3].ToString()), 2);
                        transactionDetail.dea_cust_id = dc.Id;
                        transactionDetail.added_date  = DateTime.Now;
                        transactionDetail.added_by    = u.Id;


                        string transactionType = lblTop.Text;
                        bool   x = false;
                        if (transactionType == "PURCHASE")
                        {
                            x = pdal.IncreaseProduct(transactionDetail.product_id, transactionDetail.qty);
                        }
                        else if (transactionType == "SALES")
                        {
                            x = pdal.DecreaseProduct(transactionDetail.product_id, transactionDetail.qty);
                        }

                        bool y = tdDAL.InsertTransactionDetail(transactionDetail);
                        success = w && x && y;
                    }

                    if (success == true)
                    {
                        scope.Complete();
                        MassageBox mb = new MassageBox("Transaction Success", MsgType.success);
                        mb.Show();
                        //MessageBox.Show("Transaction Completed Successfully...");
                        dgvAddedProducts.DataSource = null;
                        dgvAddedProducts.Rows.Clear();

                        txtSearch.Text        = "";
                        txtName.Text          = "";
                        txtEmail.Text         = "";
                        txtContact.Text       = "";
                        txtAddress.Text       = "";
                        txtSearchProduct.Text = "";
                        txtNamePro.Text       = "";
                        txtInventory.Text     = "0";
                        txtRate.Text          = "0";
                        txtQty.Text           = "0";
                        txtSubTotal.Text      = "0";
                        txtDiscount.Text      = "0";
                        txtVat.Text           = "0";
                        txtGrandTotal.Text    = "0";
                        txtPaidAmount.Text    = "0";
                        txtReturnAmount.Text  = "0";
                    }
                    else
                    {
                        MassageBox mb = new MassageBox("Transaction Failed", MsgType.retry);
                        mb.Show();
                        //MessageBox.Show("Transaction Failed...!!! Try again");
                    }
                }
            }catch (Exception)
            {
                MassageBox mb = new MassageBox("ERROR", MsgType.clear);
                mb.BackColor = Color.Crimson;
                mb.Show();
            }
        }
        private void btnSave_Click(object sender, EventArgs e)
        {
            transactionsBLL transaction = new transactionsBLL();

            transaction.type = lblTop.Text;

            string     deaCustName = txtName.Text;
            DeaCustBLL dc          = dcDAL.GetDeaCustIDFromName(deaCustName);

            transaction.dea_cust_id      = dc.id;
            transaction.grandTotal       = Math.Round(decimal.Parse(txtGrandTotal.Text), 2);
            transaction.transaction_date = DateTime.Now;
            transaction.tax      = decimal.Parse(txtVat.Text);
            transaction.discount = decimal.Parse(txtDiscount.Text);

            string  username = frmLogin.loggedIn;
            userBLL u        = uDAL.GetIdFromUsername(username);

            transaction.added_by           = u.id;
            transaction.transactionDetails = transactionDT;

            bool success = false;

            using (TransactionScope scope = new TransactionScope())
            {
                int transactionID = -1;

                bool w = tDAL.Insert_Transaction(transaction, out transactionID);

                for (int i = 0; i < transactionDT.Rows.Count; i++)
                {
                    transactionDetailBLL transactionDetail = new transactionDetailBLL();

                    string      ProductName = transactionDT.Rows[i][0].ToString();
                    productsBLL p           = pDAL.GetProductIDFromName(ProductName);

                    transactionDetail.product_id  = p.id;
                    transactionDetail.rate        = decimal.Parse(transactionDT.Rows[i][1].ToString());
                    transactionDetail.qty         = decimal.Parse(transactionDT.Rows[i][2].ToString());
                    transactionDetail.total       = Math.Round(decimal.Parse(transactionDT.Rows[i][3].ToString()), 2);
                    transactionDetail.dea_cust_id = dc.id;
                    transactionDetail.added_date  = DateTime.Now;
                    transactionDetail.added_by    = u.id;

                    string transactionType = lblTop.Text;
                    bool   x = false;
                    if (transactionType == "Purchase")
                    {
                        x = pDAL.IncreaseProduct(transactionDetail.product_id, transactionDetail.qty);
                    }
                    else if (transactionType == "Sales")
                    {
                        x = pDAL.DecreaseProduct(transactionDetail.product_id, transactionDetail.qty);
                    }


                    bool y = tdDAL.InsertTransactionDetail(transactionDetail);
                    success = w && x && y;
                }

                if (success == true)
                {
                    scope.Complete();

                    //Code to Print Bill
                    DGVPrinter printer = new DGVPrinter();

                    printer.Title               = "\r\n\r\n\r\n TEAM ANTIVIRUS PVT. LTD. \r\n\r\n";
                    printer.SubTitle            = "Dhaka, Bangladesh \r\n Phone: 017xxxxxxxx \r\n\r\n";
                    printer.SubTitleFormatFlags = StringFormatFlags.LineLimit | StringFormatFlags.NoClip;
                    printer.PageNumbers         = true;
                    printer.PageNumberInHeader  = false;
                    printer.PorportionalColumns = true;
                    printer.HeaderCellAlignment = StringAlignment.Near;
                    printer.Footer              = "Discount: " + txtDiscount.Text + "% \r\n" + "VAT:" + txtVat.Text + "% \r\n" + "Grand Total:" + txtGrandTotal.Text + "\r\n\r\n" + "Thank You";
                    printer.FooterSpacing       = 15;
                    printer.PrintDataGridView(pnldataGridView);

                    MessageBox.Show("Transaction Completed Successfully");

                    pnldataGridView.DataSource = null;
                    pnldataGridView.Rows.Clear();

                    txtSearch.Text        = "";
                    txtName.Text          = "";
                    txtEmail.Text         = "";
                    txtContact.Text       = "";
                    txtAddress.Text       = "";
                    txtProductSearch.Text = "";
                    txtProductName.Text   = "";
                    txtInventory.Text     = "0";
                    txtRate.Text          = "0";
                    txtVat.Text           = "0";
                    txtQty.Text           = "0";
                    txtSubTotal.Text      = "0";
                    txtGrandTotal.Text    = "0";
                    txtDiscount.Text      = "0";
                    txtPaidAmount.Text    = "0";
                    txtReturnAmount.Text  = "0";
                }
                else
                {
                    MessageBox.Show("Transaction Failed");
                }
            }
        }