Ejemplo n.º 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));
        }
Ejemplo n.º 2
0
        private void btnSave_Click_1(object sender, EventArgs e)
        {
            try
            {
                //double total;
                //DateTime today = DateTime.Now;
                //total =double.Parse(txtPrice.Text) * Int32.Parse (txtQty.Text);


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

                //pro.SaveData(pro.sqladd);



                pro.sqlselect = "SELECT * FROM tblproduct WHERE ProductId='" + lblProductId.Text + "'";

                pro.sqladd = "INSERT INTO tblproduct (ProductId,Barcode,ProductName,Description,OriginalPrice,MarkupPrice,ProductQty,CategoryId) " +
                             " VALUES ('" + lblProductId.Text + "','" + txtBarcode.Text + "','" + txtProduct.Text + "','" + txtDescription.Text + "','" + txtPrice.Text + "','" + txtMarkupPrice.Text + "',0," + cboCategory.SelectedValue + ")";

                pro.sqledit = "UPDATE tblproduct Set ProductId='" + lblProductId.Text +
                              "',Barcode='" + txtBarcode.Text +
                              "',ProductName='" + txtProduct.Text +
                              "',Description='" + txtDescription.Text +
                              "',OriginalPrice='" + txtPrice.Text +
                              "',MarkupPrice='" + txtMarkupPrice.Text +
                              "',CategoryId=" + cboCategory.SelectedValue +
                              "  WHERE ProductId = '" + lblProductId.Text + "'";

                pro.msgadd = "New Product has been saved in the database.";

                pro.msgedit = "Product has been updated in the database.";

                pro.SaveUpdate(pro.sqlselect, pro.sqladd, pro.msgadd, pro.sqledit, pro.msgedit);

                if (pro.msg == "New Product has been saved in the database.")
                {
                    pro.UpdateProductAutonumber(cboCategory);
                    pro.msg = "";
                }

                frmProduct_Load(sender, e);
            }
            catch (Exception ex)
            {
            }
        }
Ejemplo n.º 3
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            user.sqlselect = "SELECT * FROM tbluser WHERE UserId =" + lblUserId.Text;

            user.sqladd = "INSERT INTO tbluser (UserId,Fullname,User_name,Pass,UserRole) VALUES " +
                          " (" + lblUserId.Text + ",'" + txtName.Text + "','" + txtUsername.Text + "','" + txtPassword.Text + "','" + cboRole.Text + "')";

            user.msgadd = "New User has been saved in the database.";

            user.sqledit = "UPDATE tbluser SET Fullname='" + txtName.Text +
                           "',User_name='" + txtUsername.Text +
                           "',Pass='******',UserRole='" + cboRole.Text +
                           "' WHERE UserId=" + lblUserId.Text;

            user.msgedit = "User has been updated in the database.";

            user.SaveUpdate(user.sqlselect, user.sqladd, user.msgadd, user.sqledit, user.msgedit);


            btnNew_Click(sender, e);
        }