예제 #1
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            ////SQLConfig config = new SQLConfig();


            config.sqlselect = "SELECT * FROM tblcategory WHERE CategoryId=" + lblCategoryId.Text;
            config.sqladd    = "INSERT INTO tblcategory (CategoryId,Category,CategoryType,Unit) VALUES ('" + lblCategoryId.Text + "','" + txtcategory.Text + "','" + txtType.Text + "','" + txtUnit.Text + "')";
            config.sqledit   = "UPDATE tblcategory SET Category='" + txtcategory.Text + "',CategoryType='" + txtType.Text + "',Unit='" + txtUnit.Text + "' WHERE CategoryId=" + lblCategoryId.Text;
            config.msgadd    = "New Category has been saved in the database.";
            config.msgedit   = "Category has been updated in the database.";
            config.SaveUpdate(config.sqlselect, config.sqladd, config.msgadd, config.sqledit, config.msgedit);

            string autoStart = txtcategory.Text.Substring(0, 3) + "-" + txtType.Text.Substring(0, 3) + "-";

            if (categoryid == 0)
            {
                config.sqladd = "INSERT INTO tblautonumber (AutoStart,AutoEnd,AutoIncrement,CategoryId) VALUES ('" + autoStart + "',1,1," + lblCategoryId.Text + ")";
                config.SaveData(config.sqladd);
            }
            else
            {
                config.sqledit = "UPDATE tblautonumber SET AutoStart ='" + autoStart + "' WHERE CategoryId=" + lblCategoryId.Text;
                config.SaveData(config.sqledit);
            }



            frmCategory_Load(sender, e);

            //MessageBox.Show(txtcategory.Text.Substring(0, 3));
            //MessageBox.Show(txtType.Text.Substring(0, 3));
        }
예제 #2
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            try
            {
                //double total;
                DateTime today = DateTime.Now;

                if (txtBarcode.Text == "" || dtgOrderlist.Rows.Count <= 0)
                {
                    MessageBox.Show("Fields are required.", "Filled up", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                }
                else
                {
                    //total = double.Parse(txtPrice.Text) * Int32.Parse(txtQty.Text);

                    //pro.sqledit = "UPDATE tblproduct Set ProductQty = ProductQty + " + txtQty.Text  + "  WHERE Barcode = '" + txtBarcode.Text  + "'";
                    //pro.SaveData(pro.sqledit);


                    foreach (DataGridViewRow r in dtgOrderlist.Rows)
                    {
                        pro.sqledit = "UPDATE tblproduct Set ProductQty = ProductQty + " + r.Cells[8].Value + "  WHERE Barcode = '" + txtBarcode.Text + "'";
                        pro.SaveData(pro.sqledit);

                        pro.sqledit = "UPDATE tblorder Set Rem = 'Settled'  WHERE OrderId = " + r.Cells[0].Value;
                        pro.SaveData(pro.sqledit);


                        pro.sqladd = "INSERT INTO tblstockin (Barcode,DateReceived,Price,ReceivedQty,SubTotal,UserId,OrderId) " +
                                     " Values('" + txtBarcode.Text + "','" + today + "','" + txtPrice.Text +
                                     "'," + r.Cells[8].Value + ",'" + r.Cells[10].Value +
                                     "',1," + r.Cells[0].Value + ")";
                        pro.SaveData(pro.sqladd);
                    }


                    MessageBox.Show("Product has been added to the inventory.");
                    frmTransaction_Load(sender, e);
                    clearStockin();
                    txtBarcode.Clear();
                    txtBarcode.Focus();


                    //pro.sqledit = "UPDATE tblorder Set Rem = 'Settled'  WHERE OrderId = " + dtgOrderlist.CurrentRow.Cells[0].Value;
                    //pro.SaveData(pro.sqledit);


                    ////pro.sqladd = "INSERT INTO tblstockin (Barcode,DateReceived,Price,ReceivedQty,SubTotal,UserId) " +
                    ////    " Values('" + txtBarcode.Text + "','" + today + "','" + txtPrice.Text + "'," + txtQty.Text + ",'" + total + "',1)";

                    //pro.sqladd = "INSERT INTO tblstockin (Barcode,DateReceived,Price,ReceivedQty,SubTotal,UserId,OrderId) " +
                    //    " Values('" + txtBarcode.Text + "','" + today + "','" + txtPrice.Text +
                    //    "'," + dtgOrderlist.CurrentRow.Cells[8].Value + ",'" + dtgOrderlist.CurrentRow.Cells[10].Value +
                    //    "',1," + dtgOrderlist.CurrentRow.Cells[0].Value + ")";

                    //pro.SaveDataMsg(pro.sqladd, "Product has been added to the inventory.");

                    //frmTransaction_Load(sender, e);

                    //clearStockin();
                    //txtBarcode.Clear();
                    //txtBarcode.Focus();
                    //pro.sqlselect = "SELECT OrderId,Supplier,OrderDate,p.Barcode,ProductName,Description,Category,p.OriginalPrice,OrderQty,Unit,OrderTotal " +
                    //        " FROM tblcategory c, tblproduct p,tblorder o , tblsupplier s " +
                    //        " WHERE p.CategoryId=c.CategoryId AND p.Barcode=o.Barcode AND o.SupplierId=s.SupplierId AND Rem='Ordered' And p.Barcode = '" + txtBarcode.Text + "'";
                    //pro.LoadData(pro.sqlselect, dtgOrderlist);
                    //dtgOrderlist.Columns[0].Visible = false;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
예제 #3
0
        private void txtTenderAmount_KeyUp(object sender, KeyEventArgs e)
        {
            try
            {
                double   subtot = double.Parse(txtTotalAmount.Text);
                double   tender = double.Parse(txtTenderAmount.Text);
                DateTime today  = DateTime.Now;
                int      totqty = 0;

                if (e.KeyCode == Keys.Enter)
                {
                    //MessageBox.Show(subtot.ToString());
                    //MessageBox.Show(tender.ToString());


                    if (tender >= subtot)
                    {
                        pnltenderAmount.Visible = false;
                        txtTotalAmount.Size     = new Size(150, 35);
                        txtChange.Visible       = true;
                        txtAmountTender.Visible = true;
                        lblamountTender.Visible = true;
                        lblchange.Visible       = true;


                        foreach (DataGridViewRow row in dtgList.Rows)
                        {
                            pro.sqladd = "INSERT INTO tbltransaction (InvoiceNo,Barcode,TransactionDate,Price,TransVat,TransDiscount,TransactionQty,SubTotal,UserId) " +
                                         "Values (" + lblTransactionId.Text + ",'" + row.Cells[0].Value +
                                         "','" + today + "','" + row.Cells[3].Value + "','12','" + txtDiscount.Text +
                                         "','" + row.Cells[4].Value + "','" + row.Cells[5].Value + "','" + UserIdStatusStrip.Text + "')";
                            //pro.SaveDataMsg(pro.sqladd, "Transaction has been saved!");
                            pro.SaveData(pro.sqladd);

                            pro.sqledit = "UPDATE tblproduct Set ProductQty=ProductQty-" + row.Cells[4].Value + " WHERE Barcode='" + row.Cells[0].Value + "'";
                            pro.SaveData(pro.sqledit);

                            totqty += int.Parse(row.Cells[4].Value.ToString());
                        }

                        pro.sqladd = "INSERT INTO tblsummary (InvoiceNo,TransactionDate,TotalQty,TransDiscount,TotalAmount,AmountTendered,Change) " +
                                     " VALUES (" + lblTransactionId.Text + ",'" + today + "','" + totqty + "','" + txtDiscount.Text + "','" + txtTotalAmount.Text +
                                     "','" + txtAmountTender.Text + "','" + txtChange.Text + "')";
                        pro.SaveData(pro.sqladd);



                        pro.UpdateAutonumber(11);
                        dtgList.Enabled    = false;
                        txtBarcode.Enabled = false;
                        checkBox1.Enabled  = false;
                        btnVoid.Enabled    = false;
                        btnTender.Enabled  = false;
                        totqty             = 0;


                        frmInvoice frm = new frmInvoice(lblTransactionId.Text);
                        frm.ShowDialog();
                    }
                    else
                    {
                        MessageBox.Show("The amount you tendered is not valid.", "Not Valid", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    }
                }
            }
            catch (Exception ex)
            {
                // MessageBox.Show(ex.Message);
                //MessageBox.Show("The amount you tendered is not valid." +  ex.Message);
            }
        }