public void sendReqeust()
        {
            try
            {
                SqlConnection con = Connect.conn();

                reqid = Connect.AI("InventoryRequest", "requestid");


                con.Open();



                SqlCommand cmd = new SqlCommand("Insert into InventoryRequest(requestid,itemno,itemName,quantity) Values(@reqid,@ino,@name,@quant)", con);

                SqlCommand cmd2 = new SqlCommand("UPDATE denyEventSell SET state = 1 WHERE eventid = @evnt", con);



                cmd.Parameters.Add("@reqid", System.Data.SqlDbType.Int);
                cmd.Parameters.Add("@ino", System.Data.SqlDbType.Int);
                cmd.Parameters.Add("@name", System.Data.SqlDbType.VarChar);
                cmd.Parameters.Add("@quant", System.Data.SqlDbType.Int);

                cmd.Parameters["@reqid"].Value = Convert.ToInt32(reqid);
                cmd.Parameters["@ino"].Value   = Convert.ToInt32(txtItemNo.Text);
                cmd.Parameters["@name"].Value  = Convert.ToString(txtItemName.Text);
                cmd.Parameters["@quant"].Value = Convert.ToInt32(txtQuantity.Text);

                int affected = cmd.ExecuteNonQuery();

                cmd2.Parameters.Add("@evnt", System.Data.SqlDbType.Int);
                cmd2.Parameters["@evnt"].Value = Convert.ToInt32(seventid);

                int affected2 = cmd2.ExecuteNonQuery();

                if (affected == 1 && affected2 == 1)
                {
                    ino     = int.Parse(txtItemNo.Text);
                    eventid = int.Parse(seventid);

                    MessageBox.Show("Data Inserted", "SuccessFull", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    runDataGridDeny();
                }
                else
                {
                    MessageBox.Show("Please Contact Developer Team to Fix this Error... (Error Description : Data Dosent inserted to InventoryRequest Table)", "Error Detected!", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                con.Close();
            }
            catch (Exception)
            {
                MessageBox.Show("Please Check Data That You Edited or Inserted", "Wrong Input Addded", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
        private void Form1_Load(object sender, EventArgs e)
        {
            this.customerPaymentTableAdapter.Fill(this.inventoryDataSet.customerPayment);

            txtInv.Text = Connect.AI("cusPayment", "invoiceNumber").ToString();

            timer1.Start();
            Time.Text = DateTime.Now.ToLongTimeString();
            Date.Text = DateTime.Now.ToLongDateString();
            RundataGrid();
        }
        public int addTxtBoxData()
        {
            try
            {
                SqlConnection con = Connect.conn();

                if (txtName.Text != null && txtPrice.Text != null)
                {
                    id    = Connect.AI("InvtEventPack", "packid");
                    name  = txtName.Text;
                    price = double.Parse(txtPrice.Text);


                    String qry = "Insert into InvtEventPack(packid,packprice,packname) VALUES(@id,@price,@name)";

                    con.Open();

                    SqlCommand cmd = new SqlCommand(qry, con);

                    cmd.Parameters.Add("@id", System.Data.SqlDbType.Int);
                    cmd.Parameters.Add("@price", System.Data.SqlDbType.Real);
                    cmd.Parameters.Add("@name", System.Data.SqlDbType.VarChar);

                    cmd.Parameters["@id"].Value    = id;
                    cmd.Parameters["@price"].Value = price;
                    cmd.Parameters["@name"].Value  = name;

                    int status = cmd.ExecuteNonQuery();

                    con.Close();

                    return(status);
                }
                else
                {
                    return(-99);
                }
            }
            catch (Exception)
            {
                MessageBox.Show("Please Insert Correct Data to Fileds", "Wrong Input", MessageBoxButtons.OK, MessageBoxIcon.Error);
                txtName.Text  = null;
                txtPrice.Text = null;
                return(-999);
            }
        }
Example #4
0
        public void insertInventory8(String qry, String type)
        {
            if (String.Equals(type, "insert"))
            {
                eventid = Connect.AI("EventSell", "eventid"); //auto increment code
            }
            SqlConnection con = Connect.conn();


            String sql = qry;

            con.Open();


            SqlCommand cmd = new SqlCommand(sql, con);

            cmd.Parameters.Add("@eventid", System.Data.SqlDbType.Int);
            cmd.Parameters.Add("@itemCode", System.Data.SqlDbType.Int);
            cmd.Parameters.Add("@itemPrice", System.Data.SqlDbType.Real);
            cmd.Parameters.Add("@itemName", System.Data.SqlDbType.VarChar);
            cmd.Parameters.Add("@itemAmmt", System.Data.SqlDbType.Int);
            cmd.Parameters.Add("@cusid", System.Data.SqlDbType.Int);


            cmd.Parameters["@eventid"].Value   = eventid;
            cmd.Parameters["@itemPrice"].Value = double.Parse(item8price.Text);
            cmd.Parameters["@itemName"].Value  = item8N.Text;
            cmd.Parameters["@itemAmmt"].Value  = int.Parse(range8.Text);
            cmd.Parameters["@itemCode"].Value  = 008;
            cmd.Parameters["@cusid"].Value     = fname_txt.Text;



            int execute = cmd.ExecuteNonQuery();

            con.Close();

            if (execute == 1)
            {
                MessageBox.Show("        ", "Succesfully Inserted....!", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
Example #5
0
        private void btnadd_Click(object sender, EventArgs e)
        {
            SqlConnection con = Connect.conn();
            int           id  = Connect.AI("finance", "id");
            String        sql = "INSERT INTO finance(id,sale,expences,profit) VALUES(@id,1200,600,@profit)";
            SqlCommand    cmd = new SqlCommand(sql, con);

            con.Open();

            if (id == null)
            {
                id = 0;
            }
            cmd.Parameters.Add("@id", System.Data.SqlDbType.Int);
            cmd.Parameters.Add("@profit", System.Data.SqlDbType.Real);

            double getExpences = expences();
            string getSal      = sales();

            cmd.Parameters["@id"].Value     = id;
            cmd.Parameters["@profit"].Value = double.Parse(txttot.Text);



            int exec = cmd.ExecuteNonQuery();

            con.Close();

            if (exec == 1)
            {
                MessageBox.Show("Data Inserted", "Successfully", MessageBoxButtons.OK, MessageBoxIcon.Information);
                runDataGrid();
            }

            if (exec == 1)
            {
                //Change this "Test" part as you need
                MessageBox.Show("Print balance sheet", "Test", MessageBoxButtons.OK, MessageBoxIcon.Information);
                runDataGrid();
            }
        }
        private void packInsert_Load(object sender, EventArgs e)
        {
            packLoadObj  = sender;
            packLoadArgs = e;

            txtID.Text = Connect.AI("InvtEventPack", "packid").ToString();

            Clear01.Visible = false;
            Clear02.Visible = false;
            Clear03.Visible = false;
            Clear04.Visible = false;
            Clear05.Visible = false;
            Clear06.Visible = false;

            Image01 = null;
            Image02 = null;
            Image03 = null;
            Image04 = null;
            Image05 = null;
            Image06 = null;
        }
        //Insert Part
        public void insertInventory(String qry, String type)
        {
            try
            {
                if (String.Equals(type, "insert"))
                {
                    reqid = Connect.AI("InvtEventSell", "ItemCode"); //auto increment code
                }
                SqlConnection con = Connect.conn();
                String        sql = qry;

                con.Open();

                SqlCommand cmd = new SqlCommand(sql, con);

                cmd.Parameters.Add("@code", System.Data.SqlDbType.Int);
                cmd.Parameters.Add("@price", System.Data.SqlDbType.Real);
                cmd.Parameters.Add("@name", System.Data.SqlDbType.VarChar);
                cmd.Parameters.Add("@cnt", System.Data.SqlDbType.Int);

                if (picBx.Image != null)
                {
                    byte[]       images = null;
                    FileStream   stream = new FileStream(imglocation, FileMode.Open, FileAccess.Read);
                    BinaryReader reader = new BinaryReader(stream);
                    images = reader.ReadBytes((int)stream.Length);

                    cmd.Parameters.Add("@imge", System.Data.SqlDbType.Image);

                    cmd.Parameters["@imge"].Value = images;
                }

                if (String.Equals(type, "insert"))
                {
                    cmd.Parameters["@code"].Value = reqid;
                }
                else
                {
                    if (txtItemNo2.Text != null)
                    {
                        cmd.Parameters["@code"].Value = int.Parse(txtItemNo2.Text);
                    }
                    else
                    {
                        MessageBox.Show("        ", "Item Number is Empty....!", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                }
                cmd.Parameters["@price"].Value = double.Parse(txtPrice2.Text);
                cmd.Parameters["@name"].Value  = txtName2.Text;
                cmd.Parameters["@cnt"].Value   = int.Parse(txtStockCnt2.Text);


                int execute = cmd.ExecuteNonQuery();
                con.Close();

                if (execute == 1)
                {
                    if (String.Equals(type, "update"))
                    {
                        MessageBox.Show("                      ", "Succesfully Updated....!", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        runDataGridInventory();
                        ClearAll();
                    }
                    else if (String.Equals(type, "insert"))
                    {
                        MessageBox.Show("                ", "Succesfully Inserted....!", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        runDataGridInventory();
                        ClearAll();
                    }
                }
                else
                {
                    MessageBox.Show("        ", "Error Occured....!", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                }
            }
            catch (Exception)
            {
                MessageBox.Show("Please check Data That You Added ", "Wrong Input", MessageBoxButtons.OK, MessageBoxIcon.Error);
                ClearAll();
            }
        }