Example #1
0
        private void dataGridView1_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
        {
            S_Jewelry myForm = new S_Jewelry();

            myForm.btn_Refresh.Visible = false;
            myForm.btnsave.Visible     = false;


            // myForm.txt_ID.Text = this.dataGridView1.CurrentRow.Cells[0].Value.ToString();
            myForm.Stock_Type.Text  = this.dataGridView1.CurrentRow.Cells[1].Value.ToString();
            myForm.txtstock_no.Text = this.dataGridView1.CurrentRow.Cells[2].Value.ToString();

            myForm.txt_qty.Text                 = this.dataGridView1.CurrentRow.Cells[3].Value.ToString();
            myForm.txt_gem_type.Text            = this.dataGridView1.CurrentRow.Cells[4].Value.ToString();
            myForm.txt_gem_weight.Text          = this.dataGridView1.CurrentRow.Cells[5].Value.ToString();
            myForm.combo_itemk_description.Text = this.dataGridView1.CurrentRow.Cells[6].Value.ToString();
            myForm.combo_item_type.Text         = this.dataGridView1.CurrentRow.Cells[7].Value.ToString();

            myForm.txt_no_of_gems.Text           = this.dataGridView1.CurrentRow.Cells[8].Value.ToString();
            myForm.txt_no_of_other_gems.Text     = this.dataGridView1.CurrentRow.Cells[9].Value.ToString();
            myForm.txt_other_gems.Text           = this.dataGridView1.CurrentRow.Cells[10].Value.ToString();
            myForm.txt_weight_of_other_gems.Text = this.dataGridView1.CurrentRow.Cells[11].Value.ToString();

            byte[] pic = this.dataGridView1.CurrentRow.Cells[12].Value as byte[];
            if (pic != null)
            {
                MemoryStream stream = new MemoryStream(pic);
                myForm.pb1.Image = Image.FromStream(stream);
            }
            else
            {
                myForm.pb1.Image = null;
            }

            //  myForm.pb1.Text = this.dataGridView1.CurrentRow.Cells[8].Value.ToString();
            myForm.txt_cost.Text = this.dataGridView1.CurrentRow.Cells[13].Value.ToString();
            myForm.ShowDialog();



            /*S_Gems myFormg = new S_Gems();
             * myFormg.Stock_Type.Text = this.dataGridView1.CurrentRow.Cells[1].Value.ToString();
             * myFormg.txtstock_no.Text = this.dataGridView1.CurrentRow.Cells[2].Value.ToString();
             * myFormg.txtno_of_peices.Text = this.dataGridView1.CurrentRow.Cells[3].Value.ToString();
             * myFormg.txt_gems.Text = this.dataGridView1.CurrentRow.Cells[4].Value.ToString();
             * myFormg.txt_weight.Text = this.dataGridView1.CurrentRow.Cells[5].Value.ToString();
             *
             * byte[] picg = this.dataGridView1.CurrentRow.Cells[12].Value as byte[];
             * if (picg != null)
             * {
             *  MemoryStream stream = new MemoryStream(picg);
             *  myFormg.pb1.Image = Image.FromStream(stream);
             * }
             * else
             *  myFormg.pb1.Image = null;
             *
             * myFormg.txt_cost.Text = this.dataGridView1.CurrentRow.Cells[13].Value.ToString();
             * //  myForm.hello.Text = this.dataGridView1.CurrentRow.Cells[10].Value.ToString();
             * myFormg.Hide();*/
        }
Example #2
0
        private void bunifuFlatButton1_Click(object sender, EventArgs e)
        {
            S_Jewelry open = new S_Jewelry();

            open.btnupdate.Visible  = false;
            open.btn_delete.Visible = false;
            open.Show();
        }
Example #3
0
        private void dataGridView1_CellContentDoubleClick(object sender, DataGridViewCellEventArgs e)
        {
            Match m = Regex.Match(dataGridView1.CurrentRow.Cells[0].Value.ToString(), "([A-Za-z]+)([0-9]+)");

            if (m.Groups.Count != 3)
            {
                return;
            }
            string stockId = m.Groups[2].Value;
            string stockNo = m.Groups[1].Value;

            S_Jewelry myFormg = new S_Jewelry();

            myFormg.radioButton1.Checked = false;
            myFormg.radioButton1.Enabled = false;

            myFormg.btn_Refresh.Visible = false;
            myFormg.btnsave.Visible     = false;

            myFormg.Stock_Type.Text = "Jewellery";

            myFormg.txtstock_no.Text = this.dataGridView1.CurrentRow.Cells[0].Value.ToString();
            myFormg.txt_qty.Text     = "1";

            myFormg.combo_itemk_description.Text = this.dataGridView1.CurrentRow.Cells[2].Value.ToString();
            myFormg.combo_item_type.Text         = this.dataGridView1.CurrentRow.Cells[3].Value.ToString();
            myFormg.txt_no_of_gems.Text          = this.dataGridView1.CurrentRow.Cells[4].Value.ToString();
            myFormg.txt_gem_type.Text            = this.dataGridView1.CurrentRow.Cells[5].Value.ToString();
            myFormg.txt_gem_weight.Text          = this.dataGridView1.CurrentRow.Cells[6].Value.ToString();
            myFormg.txt_cost.Text = this.dataGridView1.CurrentRow.Cells[7].Value.ToString();

            myFormg.txt_no_of_other_gems.Text     = this.dataGridView1.CurrentRow.Cells[13].Value.ToString();
            myFormg.txt_other_gems.Text           = this.dataGridView1.CurrentRow.Cells[14].Value.ToString();
            myFormg.txt_weight_of_other_gems.Text = this.dataGridView1.CurrentRow.Cells[15].Value.ToString();

            //   myFormg.cmbStockType.Enabled = false;
            //  myFormg.txtstock_no.Enabled = false;

            using (var cmd = new SqlCommand("SELECT Image FROM Stock_Entry WHERE Stock_ID=@Stock_ID AND Stock_No= @Stock_No", conn))
            {
                cmd.Parameters.AddWithValue("Stock_ID", stockId);
                cmd.Parameters.AddWithValue("Stock_No", stockNo);
                using (var Reader = cmd.ExecuteReader())
                {
                    if (Reader.Read())
                    {
                        MemoryStream ms = new MemoryStream(Reader["Image"] as byte[]);
                        myFormg.pb1.Image = Image.FromStream(ms);
                    }
                }
            }
            myFormg.ShowDialog();
        }
Example #4
0
        private void btnsave_Click(object sender, EventArgs e)
        {
            errorProvider1.Clear();
            if (txtstock_no.Text.Length <= 0)
            {
                errorProvider1.SetError(txtstock_no, "This field cannot be empty, Select a Stock No (UG/MG)");
            }
            else if (txtno_of_peices.Text.Length <= 0)
            {
                errorProvider1.SetError(txtno_of_peices, "This field cannot be empty, Qauntity of Gems");
            }
            else if (txt_gems.Text.Length <= 0)
            {
                errorProvider1.SetError(txt_gems, "Cannot be empty, Select Gem Type");
            }
            else if (txt_weight.Text.Length <= 0)
            {
                errorProvider1.SetError(txt_weight, "This field cannot be empty, Enter the Weight of Gems");
            }
            else if (txt_cost.Text.Length <= 0)
            {
                errorProvider1.SetError(txt_cost, "Cannot be empty, Enter the Cost of Gems");
            }
            else if (!atLeastOneImage())
            {
                // errorProvider1.SetError(pb1, "Please add an Image");
                errorProvider1.SetError(pictureBox1, "Please add an Image");
            }
            else
            {
                conn.Close();
                conn.Open();

                var tx = conn.BeginTransaction();

                try
                {
                    SqlCommand command = new SqlCommand("INSERT INTO Status_Of_Stocks VALUES (@StockID,@StockNo,@StockType,@Qty,@Weight,@Cost)", conn, tx);
                    command.Parameters.AddWithValue("@StockNo", stockNo);
                    command.Parameters.AddWithValue("@StockID", stockId);
                    command.Parameters.AddWithValue("@StockType", "Gems");
                    command.Parameters.AddWithValue("@Qty", txtno_of_peices.Text);
                    command.Parameters.AddWithValue("@Weight", txt_weight.Text);
                    command.Parameters.AddWithValue("@Cost", txt_cost.Text);
                    command.ExecuteNonQuery();

                    String    query;
                    S_Jewelry sel = new S_Jewelry();

                    command.Parameters.AddWithValue("@StockNo", stockNo);
                    command.Parameters.AddWithValue("@StockId", stockId);

                    query   = "INSERT INTO Stock_Entry VALUES(@StockID,@stock_no,@Stock_Type,@No_of_pieces,@Gem_Type,@Weight,@Item_Description,@Item_Type,@No_of_Gems,@No_of_other_Gems,@Other_Gems,@Weight_of_other_Gems,@Cost,@Created_Date,@Updated_Date,@User_ID,@Update_UserID,@Imagepath,@CurrentImagePath)";
                    command = new SqlCommand(query, conn, tx);
                    command.Parameters.AddWithValue("@StockID", stockId);
                    command.Parameters.AddWithValue("@stock_no", stockNo);

                    //combining the stockID
                    command.Parameters.Add("@Stock_Type", SqlDbType.VarChar);
                    command.Parameters["@Stock_Type"].Value = Stock_Type.Text;

                    command.Parameters.Add("@No_of_pieces", SqlDbType.Int);
                    command.Parameters["@No_of_pieces"].Value = Convert.ToInt32(txtno_of_peices.Text);

                    command.Parameters.Add("@Gem_Type", SqlDbType.NVarChar);
                    command.Parameters["@Gem_Type"].Value = txt_gems.Text;

                    command.Parameters.Add("@Weight", SqlDbType.Float);
                    command.Parameters["@Weight"].Value = Convert.ToDouble(txt_weight.Text);

                    command.Parameters.Add("@Item_Description", SqlDbType.NVarChar);
                    command.Parameters["@Item_Description"].Value = sel.combo_itemk_description.Text;

                    command.Parameters.Add("@Item_Type", SqlDbType.NVarChar);
                    command.Parameters["@Item_Type"].Value = sel.combo_item_type.Text;

                    command.Parameters.Add("@No_of_Gems", SqlDbType.Int);
                    command.Parameters["@No_of_Gems"].Value = 0;

                    command.Parameters.Add("@No_of_other_Gems", SqlDbType.Int);
                    command.Parameters["@No_of_other_Gems"].Value = 0;

                    command.Parameters.Add("@Other_Gems", SqlDbType.NVarChar);
                    command.Parameters["@Other_Gems"].Value = "";

                    command.Parameters.Add("@Weight_of_other_Gems", SqlDbType.Float);
                    command.Parameters["@Weight_of_other_Gems"].Value = 0.0;

                    //MemoryStream stream = new MemoryStream();
                    //pictureBoxes[currentPicture].Image.Save(stream, System.Drawing.Imaging.ImageFormat.Jpeg);
                    //byte[] pic = stream.ToArray();
                    //command.Parameters.Add("@image", SqlDbType.Binary);
                    //command.Parameters["@image"].Value = pic;

                    command.Parameters.Add("@Cost", SqlDbType.Decimal);
                    command.Parameters["@Cost"].Value = Convert.ToDouble(txt_cost.Text);

                    command.Parameters.Add("@Created_Date", SqlDbType.DateTime);
                    command.Parameters["@Created_Date"].Value = label11.Text;

                    command.Parameters.Add("@Updated_Date", SqlDbType.DateTime);
                    command.Parameters["@Updated_Date"].Value = label11.Text;

                    command.Parameters.Add("@User_ID", SqlDbType.NVarChar);
                    command.Parameters["@User_ID"].Value = hello.Text;

                    command.Parameters.Add("@Update_UserID", SqlDbType.NVarChar);
                    command.Parameters["@Update_UserID"].Value = "";

                    command.Parameters.Add("@Imagepath", SqlDbType.NVarChar);

                    String path = TB_File_Path.Text + txtstock_no.Text + "\\";
                    command.Parameters["@Imagepath"].Value = path;

                    // ADD the currentimagepath
                    if (!Directory.Exists(path))
                    {
                        Directory.CreateDirectory(path);
                    }
                    command.Parameters.Add("@CurrentImagePath", SqlDbType.NVarChar);
                    for (int i = 0; i < pictureBoxes.Length; ++i)
                    {
                        if (pictureIsNew[i])
                        {
                            string targetPath = String.Format("{0}img-{1:D4}{2}", path, i, Path.GetExtension(picturePaths[i]));

                            if (i == currentPicture)
                            {
                                command.Parameters["@CurrentImagePath"].Value = targetPath;
                            }

                            File.Copy(picturePaths[i], targetPath, true);
                        }
                    }
                    //command.Parameters["@CurrentImagePath"].Value = TB_File_Path.Text + txtstock_no.Text + "\\" + Path.GetFileName(picturePaths[currentPicture]);
                    //command.Parameters["@CurrentImagePath"].Value = picturePaths[currentPicture];



                    command.ExecuteNonQuery();
                    tx.Commit();
                    conn.Close();

                    MessageBox.Show("You've inserted successfully!", "Successful Message", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    this.Hide();
                }

                catch (Exception ex)
                {
                    tx.Rollback();
                    MessageBox.Show(ex.ToString(), "Error Message", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
        }