Пример #1
0
        private void productListToolStripMenuItem_Click(object sender, EventArgs e)
        {
            Stock_List go = new Stock_List();

            go.MdiParent = this;
            go.Show();
        }
Пример #2
0
        private void lnkStocklist_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            this.Hide();
            Stock_List go = new Stock_List();

            go.MdiParent = this.ParentForm;
            go.Show();
        }
Пример #3
0
 private void productListToolStripMenuItem_Click(object sender, EventArgs e)
 {
     if (Application.OpenForms["Stock_List"] == null)
     {
         Stock_List go = new Stock_List();
         go.MdiParent = this;
         go.Show();
     }
     else
     {
         MessageBox.Show("Stock windows is already open");
     }
 }
Пример #4
0
        private void lnkDelete_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            DialogResult result = MessageBox.Show("Do you want to Delete?", "Yes or No", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2);

            if (result == DialogResult.Yes)
            {
                if (lblItemcode.Text == "-")
                {
                    // MessageBox.Show("You are Not able to Update");
                    MessageBox.Show("You are Not able to Delete", "Button3 Title", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }
                else
                {
                    try
                    {
                        string sql = "delete from purchase where product_id ='" + lblItemcode.Text + "'";
                        DataAccess.ExecuteSQL(sql);

                        picItemimage.InitialImage.Dispose();
                        string path = Application.StartupPath + @"\ITEMIMAGE\";
                        System.IO.File.Delete(path + @"\" + lblimagename.Text);
                        MessageBox.Show("Successfully Data Delete !", "Successful", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);

                        Stock_List go = new Stock_List();
                        go.MdiParent = this.ParentForm;
                        go.Show();
                        this.Close();
                        ClearForm();
                    }
                    catch (Exception exp)
                    {
                        MessageBox.Show("Sorry\r\n You have to Check the Data" + exp.Message);
                    }
                }
            }
        }
Пример #5
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            if (txtProductCode.Text == "")
            {
                MessageBox.Show("Please Insert Product Code/ Item Bar-code");
                txtProductCode.Focus();
            }
            else if (txtProductName.Text == "")
            {
                MessageBox.Show("Please Insert  Product Name");
                txtProductName.Focus();
            }
            else if (txtdiscount.Text == "")
            {
                txtdiscount.Text = "0";
                txtdiscount.Focus();
            }
            else if (txtProductQty.Text == "")
            {
                MessageBox.Show("Please Insert Product Quantity");
                txtProductQty.Focus();
            }
            else if (txtCostPrice.Text == "")
            {
                MessageBox.Show("Please Insert Product Cost Price / Buy price ");
                txtCostPrice.Focus();
            }

            else if (txtSalesPrice.Text == "")
            {
                MessageBox.Show("Please Insert Product  Sales Price");
                txtSalesPrice.Focus();
            }
            else if (ComboCategory.Text == "")
            {
                MessageBox.Show("Please Insert Product Category");
                ComboCategory.Focus();
            }
            else if (cmboShopid.Text == "")
            {
                MessageBox.Show("Please Select Branch name ");
                cmboShopid.Focus();
            }
            else if (cmbSupplier.Text == "")
            {
                MessageBox.Show("Please Select Supplier Name");
                cmbSupplier.Focus();
            }
            else
            {
                try
                {
                    string pid    = txtProductCode.Text;
                    string pname  = txtProductName.Text;
                    double quan   = Convert.ToDouble(txtProductQty.Text);
                    double cprice = Convert.ToDouble(txtCostPrice.Text);
                    double sprice = Convert.ToDouble(txtSalesPrice.Text);

                    double ctotalpri = quan * cprice;
                    double rtotalpri = quan * sprice;
                    double discount  = Convert.ToDouble(txtdiscount.Text);

                    int taxapply;
                    if (chktaxapply.Checked)
                    {
                        taxapply = 1;  //1 = Tax apply
                    }
                    else
                    {
                        taxapply = 0; // 0 = Tax not apply
                    }

                    int kitchenDisplaythisitem;
                    if (chkkitchenDisplay.Checked)
                    {
                        kitchenDisplaythisitem = 3; // 3 = It's show display on kitchen display
                    }
                    else
                    {
                        kitchenDisplaythisitem = 1; // 1 = it's not show on ditcken display.
                    }
                    //New Insert / New Entry
                    if (lblItemcode.Text == "-")
                    {
                        string imageName = pid + lblFileExtension.Text;
                        string sql1      = " insert into purchase (product_id, product_name, product_quantity, cost_price, retail_price, total_cost_price, " +
                                           " total_retail_price, category, supplier , imagename, discount, taxapply, Shopid , status) " +
                                           " values ('" + pid + "', '" + pname + "', '" + quan + "', '" + cprice + "', '" + sprice + "', '" + ctotalpri + "', " +
                                           " '" + rtotalpri + "', '" + ComboCategory.Text + "', '" + cmbSupplier.Text + "' , '" + imageName + "', " +
                                           " '" + discount + "' , '" + taxapply + "' , '" + cmboShopid.SelectedValue + "' , '" + kitchenDisplaythisitem + "')";
                        DataAccess.ExecuteSQL(sql1);

                        //Add to purchase history - New item history
                        insertpurchasehistory("NEW", quan, DateTime.Now.ToString("yyyy-MM-dd"));

                        //picture upload  /////////////////
                        //  if (openFileDialog1.FileName != string.Empty)
                        // {
                        string path = Application.StartupPath + @"\ITEMIMAGE\";
                        System.IO.File.Delete(path + @"\" + imageName);
                        if (!System.IO.Directory.Exists(path))
                        {
                            System.IO.Directory.CreateDirectory(Application.StartupPath + @"\ITEMIMAGE\");
                        }
                        string filename = path + @"\" + openFileDialog1.SafeFileName;
                        picItemimage.Image.Save(filename, System.Drawing.Imaging.ImageFormat.Png);
                        System.IO.File.Move(path + @"\" + openFileDialog1.SafeFileName, path + @"\" + imageName);
                        //   }

                        MessageBox.Show("Item hase been saved Successfully", "Successful", MessageBoxButtons.OK, MessageBoxIcon.Information);

                        if (UserInfo.usertype == "1")
                        {
                            Stock_List go = new Stock_List();
                            go.MdiParent = this.ParentForm;
                            go.Show();
                            this.Close();
                        }
                        else
                        {
                            // btnItemLink.Visible = false;
                        }


                        // ClearForm();
                    }
                    else  //Update
                    {
                        string imageName;
                        if (lblFileExtension.Text == "item.png") //if not select image
                        {
                            imageName = lblimagename.Text;
                        }
                        else  // select image
                        {
                            imageName = lblItemcode.Text + lblFileExtension.Text;
                        }

                        string sql = " update purchase set product_name = '" + txtProductName.Text + "', product_quantity= '" + txtProductQty.Text + "', " +
                                     " cost_price = '" + txtCostPrice.Text + "', retail_price= '" + txtSalesPrice.Text + "', total_cost_price = '" + ctotalpri + "', " +
                                     " total_retail_price= '" + rtotalpri + "', category = '" + ComboCategory.Text + "', supplier = '" + cmbSupplier.Text + "',  " +
                                     " imagename = '" + imageName + "' , discount   = '" + discount + "' , taxapply = '" + taxapply + "' , " +
                                     " Shopid = '" + cmboShopid.SelectedValue + "' , status =  '" + kitchenDisplaythisitem + "' " +
                                     " where product_id = '" + lblItemcode.Text + "'";
                        DataAccess.ExecuteSQL(sql);

                        /////////////////////////////////////////////Update image //////////////////////////////////////////////////////
                        if (lblFileExtension.Text != "item.png")   // if select image
                        {
                            picItemimage.InitialImage.Dispose();
                            string path = Application.StartupPath + @"\ITEMIMAGE\";
                            System.IO.File.Delete(path + @"\" + lblimagename.Text);
                            if (!System.IO.Directory.Exists(path))
                            {
                                System.IO.Directory.CreateDirectory(Application.StartupPath + @"\ITEMIMAGE\");
                            }
                            string filename = path + @"\" + openFileDialog1.SafeFileName;
                            picItemimage.Image.Save(filename, System.Drawing.Imaging.ImageFormat.Png);
                            System.IO.File.Move(path + @"\" + openFileDialog1.SafeFileName, path + @"\" + imageName);
                        }


                        MessageBox.Show("Successfully Data Updated!", "Successful", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        //loadData();
                        if (UserInfo.usertype == "1")
                        {
                            Stock_List go = new Stock_List();
                            go.MdiParent = this.ParentForm;
                            go.Show();
                            this.Close();
                        }
                        else
                        {
                            // btnItemLink.Visible = false;
                        }
                    }
                }
                catch (Exception exp)
                {
                    MessageBox.Show("Sorry\r\n this id already added \n" + exp.Message);
                }
            }
            //this.Hide();
        }