private void Edit_reqst_odr_Load(object sender, EventArgs e)
        {
            String         sql = "SELECT*FROM tbl_AddS_Supplier";
            SqlDataAdapter get = new SqlDataAdapter(sql, ConnectionDB.Connection());
            DataTable      ns  = new DataTable();

            get.Fill(ns);
            for (int i = 0; i < ns.Rows.Count; i++)
            {
                cbxSupplier.Items.Add(ns.Rows[i]["Business_Name"]);
            }



            String         csql = "SELECT*FROM tbl_catogory";
            SqlDataAdapter cget = new SqlDataAdapter(csql, ConnectionDB.Connection());
            DataTable      cdt  = new DataTable();

            cget.Fill(cdt);
            for (int i = 0; i < cdt.Rows.Count; i++)
            {
                cbx_qty_ctgy.Items.Add(cdt.Rows[i]["catogory"]);
            }



            String         bsql = "SELECT*FROM tbl_brande";
            SqlDataAdapter bget = new SqlDataAdapter(bsql, ConnectionDB.Connection());
            DataTable      bdt  = new DataTable();

            bget.Fill(bdt);
            for (int i = 0; i < bdt.Rows.Count; i++)
            {
                cbx_qty_Brand.Items.Add(bdt.Rows[i]["Brande"]);
            }



            String         tsql = "SELECT*FROM tbl_itype";
            SqlDataAdapter tget = new SqlDataAdapter(tsql, ConnectionDB.Connection());
            DataTable      tdt  = new DataTable();

            tget.Fill(tdt);
            for (int i = 0; i < tdt.Rows.Count; i++)
            {
                cbx_itmtype.Items.Add(tdt.Rows[i]["Item_type"]);
            }


            cbx_qty_ctgy.DropDownStyle      = System.Windows.Forms.ComboBoxStyle.DropDown;
            cbx_qty_ctgy.AutoCompleteMode   = AutoCompleteMode.SuggestAppend;
            cbx_qty_ctgy.AutoCompleteSource = AutoCompleteSource.ListItems;



            cbx_qty_Brand.DropDownStyle      = System.Windows.Forms.ComboBoxStyle.DropDown;
            cbx_qty_Brand.AutoCompleteMode   = AutoCompleteMode.SuggestAppend;
            cbx_qty_Brand.AutoCompleteSource = AutoCompleteSource.ListItems;


            lblOrderNo.Text = View_Requst_Order.dgv_rqet.CurrentRow.Cells["Order_No"].Value.ToString();
            DateTime Odt = DateTime.Parse(View_Requst_Order.dgv_rqet.CurrentRow.Cells["Order_Date"].Value.ToString());

            dp_rest_odr.Text = Odt.ToShortDateString();

            txtMobile.Text       = View_Requst_Order.dgv_rqet.CurrentRow.Cells["Mobile"].Value.ToString();
            txt_email.Text       = View_Requst_Order.dgv_rqet.CurrentRow.Cells["Email"].Value.ToString();
            txtDiscription.Text  = View_Requst_Order.dgv_rqet.CurrentRow.Cells["Discription"].Value.ToString();
            cbx_qty_ctgy.Text    = View_Requst_Order.dgv_rqet.CurrentRow.Cells["Catogory"].Value.ToString();
            cbxSupplier.Text     = View_Requst_Order.dgv_rqet.CurrentRow.Cells["Supplier"].Value.ToString();
            cbx_qty_S_ctgy.Text  = View_Requst_Order.dgv_rqet.CurrentRow.Cells["Sub_Catogory"].Value.ToString();
            cbx_qty_Brand.Text   = View_Requst_Order.dgv_rqet.CurrentRow.Cells["Brande"].Value.ToString();
            cbx_itmtype.Text     = View_Requst_Order.dgv_rqet.CurrentRow.Cells["Item_Type"].Value.ToString();
            txt_inme.Text        = View_Requst_Order.dgv_rqet.CurrentRow.Cells["Name"].Value.ToString();
            numericUpDown1.Value = Convert.ToDecimal(View_Requst_Order.dgv_rqet.CurrentRow.Cells["Quntity"].Value.ToString());
        }
Exemplo n.º 2
0
        private void btn_ok_Click(object sender, EventArgs e)
        {
            ep_iname.SetError(txtAddItemItemName, "");
            ep_isupp.SetError(cbxAddItemItemType, "");
            ep_ibrnd.SetError(cbxAddItemBrande, "");
            ep_ictogry.SetError(cbxAddItemCatogory, "");
            ep_isubCotory.SetError(cbxAddItemSubCatogory, "");


            SqlDataReader cdr = wrty.select_cusNo(Warranty_Details.dgvw.CurrentRow.Cells["Invoice_No"].Value.ToString());

            if (cdr.Read())
            {
                ccno   = cdr["Coustomer_No"].ToString();
                InvDt  = Convert.ToDateTime(cdr["Invoice_Date"]);
                ipmthd = cdr["Payment_Method"].ToString();
            }


            //try
            //{

            if (txtAddItemBarcode.Text != "" || txtAddItemSerial.Text != "")
            {
                if (txtAddItemItemName.Text != "" && cbxAddItemCatogory.Text != "" && cbxAddItemSubCatogory.Text != "" && cbxAddItemBrande.Text != "")
                {
                    if (txtAddItemSerial.Text == "")
                    {
                        txtAddItemSerial.Text = txtAddItemBarcode.Text;
                    }

                    SqlDataReader ddr = wrty.select_invo_backI(Warranty_Details.dgvw.CurrentRow.Cells["Item_No"].Value.ToString(), Warranty_Details.dgvw.CurrentRow.Cells["Invoice_No"].Value.ToString());
                    if (ddr.Read())
                    {
                        inom      = ddr["Item_No"].ToString();
                        inme      = ddr["Item_Name"].ToString();
                        iserial   = ddr["Serial_No"].ToString();
                        iselpiz   = ddr["Sales_Price"].ToString();
                        ipurpiz   = ddr["Purchase_Price"].ToString();
                        ictgry    = ddr["Catogory"].ToString();
                        isubctgry = ddr["Sub_Catogory"].ToString();
                        ibrnd     = ddr["Brande"].ToString();
                        ibcode    = ddr["Barcode"].ToString();
                        iwrrty    = ddr["Warranty"].ToString();
                        isuppl    = ddr["Supplier"].ToString();
                        itpe      = ddr["Item_Type"].ToString();
                        idescri   = ddr["Discription"].ToString();


                        wrty.insert_retn_itm(inom, iserial, inme, Convert.ToDecimal(iselpiz), Convert.ToDecimal(ipurpiz), Convert.ToDecimal("0"), ibcode, ictgry, isubctgry, ibrnd, itpe, isuppl, iwrrty, idescri);
                        //MessageBox.Show("add to return item");
                    }

                    decimal pfit = (Convert.ToDecimal(iselpiz)) - (Convert.ToDecimal(ipurpiz));


                    Invo.insert_Invoice_detalis(iNo.ToString(), InvDt, lbl_itNo.Text, txtAddItemSerial.Text, txtAddItemItemName.Text, Convert.ToDecimal(iselpiz), Convert.ToDecimal(ipurpiz), txtAddItemBarcode.Text, cbxAddItemCatogory.Text, cbxAddItemSubCatogory.Text, cbxAddItemBrande.Text, iwrrty, isuppl, cbxAddItemItemType.Text, txtAddItemDiscription.Text, pfit, "Ok", "1");
                    // MessageBox.Show("new itttttttttmss changgggg");


                    Invo.insert_Invoice(iNo.ToString(), InvDt, Convert.ToDecimal(iselpiz), (Convert.ToDecimal(iselpiz)), Convert.ToDecimal("0"), ipmthd, "*" + txtAddItemItemName.Text, New_invoice.sref.Text, ccno, Convert.ToDecimal(iselpiz), Convert.ToDecimal("0"), Convert.ToDecimal("0"), "Ok");
                    //MessageBox.Show("ADd new invo");

                    wrty.update_item_status(Warranty_Details.dgvw.CurrentRow.Cells["Invoice_No"].Value.ToString(), Warranty_Details.dgvw.CurrentRow.Cells["Item_No"].Value.ToString(), "Return");
                    //MessageBox.Show("update oled invo");


                    wrty.addWary_foundItm(Warranty_Details.dgvw.CurrentRow.Cells["Warranty_No"].Value.ToString(), Warranty_Details.dgvw.CurrentRow.Cells["Invoice_No"].Value.ToString(), lbl_itNo.Text, txtAddItemItemName.Text, txtAddItemSerial.Text, txtAddItemBarcode.Text, cbxAddItemCatogory.Text, cbxAddItemSubCatogory.Text, cbxAddItemBrande.Text, cbxAddItemItemType.Text, txtAddItemDiscription.Text);
                    // MessageBox.Show("warranty found item");

                    wty_dtail_inconplete.anorItm = true;
                    if (MessageBox.Show("Warranty complted by another Item", "Sharp creation", MessageBoxButtons.OK, MessageBoxIcon.Information) == DialogResult.OK)
                    {
                        if (cb_printi.Checked == true)
                        {
                            //==========================================================================================================================

                            SqlDataReader ziddr = Invo.select_invoNo(iNo.ToString());
                            if (ziddr.Read())
                            {
                                invodate = Convert.ToDateTime(ziddr["Invoice_Date"].ToString());
                                total    = ziddr["Total_Price"].ToString();
                                paid     = ziddr["Paid_Price"].ToString();
                                blnc     = ziddr["Balance"].ToString();
                                cusnom   = ziddr["Coustomer_No"].ToString();
                                paymethd = ziddr["Payment_Method"].ToString();
                                grantota = ziddr["Grande_total"].ToString();
                                disc     = ziddr["Discount"].ToString();
                                tax      = ziddr["Tax"].ToString();
                            }

                            SqlDataReader zdrcus = Invo.select_incus(cusnom);
                            if (zdrcus.Read())
                            {
                                fname = zdrcus["First_Name"].ToString();
                                lnme  = zdrcus["Last_Name"].ToString();
                                add1  = zdrcus["Address_Line1"].ToString();
                                add2  = zdrcus["Address_Line2"].ToString();
                                mobl  = zdrcus["Mobile"].ToString();
                            }
                            else
                            {
                                fname = "N/A";
                                lnme  = "N/A";
                                add1  = "N/A";
                                add2  = "N/A";
                                mobl  = "N/A";
                            }



                            String         ibsql = "SELECT*FROM tbl_Invoice_details WHERE Invoice_No='" + iNo + "'";
                            SqlDataAdapter ibget = new SqlDataAdapter(ibsql, ConnectionDB.Connection());
                            DataTable      ibns  = new DataTable();
                            ibget.Fill(ibns);
                            for (int ib = 0; ib < ibns.Rows.Count; ib++)
                            {
                                itmno      = ibns.Rows[ib]["Item_No"].ToString();
                                itmNme     = ibns.Rows[ib]["Item_Name"].ToString();
                                itmseril   = ibns.Rows[ib]["Serial_No"].ToString();
                                itsalepriz = ibns.Rows[ib]["Sales_Price"].ToString();
                                itmctgy    = ibns.Rows[ib]["Catogory"].ToString();
                                itmsbctgy  = ibns.Rows[ib]["Sub_Catogory"].ToString();
                                itmbrnd    = ibns.Rows[ib]["Brande"].ToString();
                                itmwarrty  = ibns.Rows[ib]["Warranty"].ToString();


                                iqty = ibns.Rows[ib]["Quntity"].ToString();



                                //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ check- is bill table Null...? ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++//
                                String         emty_ibl    = "SELECT*FROM tbl_Invoice_bill";
                                SqlDataAdapter iigemty_bil = new SqlDataAdapter(emty_ibl, ConnectionDB.Connection());
                                DataTable      iemty_bil   = new DataTable();
                                iigemty_bil.Fill(iemty_bil);
                                if (0 != iemty_bil.Rows.Count)     // does not exist
                                {
                                    //___________________________________________________________________________________________________________________________
                                    SqlDataReader slct_billDR = Invo.select_invtmp_bil(itmctgy, itmsbctgy, itmbrnd);
                                    if (slct_billDR.Read())
                                    {
                                        string bsril, bqtyy, u_piz; decimal n_qty;

                                        bsril = slct_billDR["Serial_No"].ToString();
                                        bqtyy = slct_billDR["Quantity"].ToString();
                                        u_piz = slct_billDR["Unit_Price"].ToString();
                                        n_qty = Convert.ToDecimal(bqtyy) + Convert.ToDecimal(iqty);

                                        Invo.Updte_invc_bill(itmctgy, itmsbctgy, itmbrnd, n_qty, (Convert.ToDecimal(u_piz) * n_qty), bsril + "," + itmseril);
                                        //MessageBox.Show("update_Dtail");
                                    }
                                    else
                                    {
                                        try
                                        {
                                            Invo.insert_Invoice_Bill(iNo.ToString(), invodate, fname + " " + lnme, add1 + " " + add2, mobl, Convert.ToDecimal(grantota), Convert.ToDecimal(disc), Convert.ToDecimal(tax), Convert.ToDecimal(total), Convert.ToDecimal(paid), paymethd, Convert.ToDecimal(blnc), itmseril, itmctgy, itmsbctgy, itmbrnd, itmbrnd + " " + itmNme + " " + itmctgy + " " + itmsbctgy + " \nWarranty- " + itmwarrty, Convert.ToDecimal(Convert.ToDecimal(itsalepriz) / Convert.ToDecimal(iqty)), Convert.ToDecimal(iqty), Convert.ToDecimal(itsalepriz));

                                            //MessageBox.Show("Invoice bill add");
                                        }
                                        catch (Exception ex)
                                        { MessageBox.Show(ex.Message); }
                                    }

                                    //___________________________________________________________________________________________________________________________
                                }
                                else
                                {
                                    try
                                    {
                                        Invo.insert_Invoice_Bill(iNo.ToString(), invodate, fname + " " + lnme, add1 + " " + add2, mobl, Convert.ToDecimal(grantota), Convert.ToDecimal(disc), Convert.ToDecimal(tax), Convert.ToDecimal(total), Convert.ToDecimal(paid), paymethd, Convert.ToDecimal(blnc), itmseril, itmctgy, itmsbctgy, itmbrnd, itmbrnd + " " + itmNme + " " + itmctgy + " " + itmsbctgy + " \nWarranty- " + itmwarrty, Convert.ToDecimal(Convert.ToDecimal(itsalepriz) / Convert.ToDecimal(iqty)), Convert.ToDecimal(iqty), Convert.ToDecimal(itsalepriz));

                                        //MessageBox.Show("Invoice bill add");
                                    }
                                    catch (Exception ex)
                                    { MessageBox.Show(ex.Message); }
                                }
                            }

                            Bill invoBil = new Bill();
                            invoBil.ShowDialog();



                            //============================================================================================================================



                            //============================================================================================================================
                        }

                        //============================================================================================================================



                        wty_dtail_inconplete.bt_save = true;

                        this.Close();
                    }
                }
                else
                {
                    if (txtAddItemItemName.Text == "")
                    {
                        ep_iname.SetError(txtAddItemItemName, "Enter Item name");
                    }
                    if (cbxAddItemItemType.Text == "")
                    {
                        ep_isupp.SetError(cbxAddItemItemType, "Choose type");
                    }
                    if (cbxAddItemBrande.Text == "")
                    {
                        ep_ibrnd.SetError(cbxAddItemBrande, "Choose Item Brande");
                    }
                    if (cbxAddItemCatogory.Text == "")
                    {
                        ep_ictogry.SetError(cbxAddItemCatogory, "Choose Item Catogary");
                    }
                    if (cbxAddItemSubCatogory.Text == "")
                    {
                        ep_isubCotory.SetError(cbxAddItemSubCatogory, "Choose Item sub Catogary");
                    }


                    tp_required.Show("Fill Require fileds", btn_ok, 5000);
                }
            }

            else
            {
                tp_seril_barcobe.Show("Must Enter Serial or Barcode For Iditify Items", txtAddItemSerial, 4000);
            }


            //}
            //catch (Exception ee)
            //{ MessageBox.Show(ee.Message); }
        }
Exemplo n.º 3
0
        private void cbx_month_SelectedIndexChanged(object sender, EventArgs e)
        {
            errorProvider_Unme.SetError(cbx_usernn, "");
            errorProvider_yer.SetError(cbx_year, "");
            errorProvider_mon.SetError(cbx_month, "");

            lbl_tot_sal.Text       = "N/A";
            lbl_reced_sal.Text     = "N/A";
            lbl_rest.Text          = "N/A";
            lbl_adition_reced.Text = "N/A";

            if (cbx_usernn.Text != "" && cbx_year.Text != "" && cbx_month.Text != "")
            {
                string         sql = "SELECT * FROM tbl_Salary_Received WHERE User_Name='" + cbx_usernn.Text + "' AND Year='" + cbx_year.Text + "' ";
                SqlDataAdapter da  = new SqlDataAdapter(sql, ConnectionDB.Connection());
                dtbl = new DataTable();
                da.Fill(dtbl);
                BindingSource bnsue = new BindingSource();
                bnsue.DataSource          = dtbl;
                dgv_get_histry.DataSource = bnsue;
                da.Update(dtbl);

                DataView dv = new DataView(dtbl);
                dv.RowFilter = "Month like '%" + cbx_month.Text + "%' ";
                dgv_get_histry.DataSource = dv;



                SqlDataReader hsdr = pay_op.select_sal_histy(cbx_usernn.Text, cbx_year.Text, cbx_month.Text);
                if (hsdr.Read())
                {
                    lbl_tot_sal.Text       = hsdr["Total_Salary"].ToString();
                    lbl_reced_sal.Text     = hsdr["Received_Salary"].ToString();
                    lbl_rest.Text          = hsdr["Rest_Salary"].ToString();
                    lbl_adition_reced.Text = hsdr["Additional_Received"].ToString();
                }
                if (cbx_year.Text == DB_yer && cbx_month.Text == DB_mon)
                {
                    lbl_tot_sal.Text       = "N/A";
                    lbl_reced_sal.Text     = "N/A";
                    lbl_rest.Text          = "N/A";
                    lbl_adition_reced.Text = "N/A";
                }
            }
            else
            {
                if (cbx_usernn.Text == "")
                {
                    errorProvider_Unme.SetError(cbx_usernn, "Plese Select Uesr Name");
                }

                if (cbx_year.Text == "")
                {
                    errorProvider_yer.SetError(cbx_year, "Plese Select Year");
                }

                if (cbx_month.Text == "")
                {
                    errorProvider_mon.SetError(cbx_month, "Plese Select Month");
                }
            }
        }
Exemplo n.º 4
0
        private void btnCreateAccount_Click(object sender, EventArgs e)
        {
            alrady = false;
            errorProvider_fnme.SetError(txt_FirstName, "");
            errorProvider_lnme.SetError(txt_LastName, "");
            errorProvider_add1.SetError(txt_AddLine1, "");
            errorProvider_add2.SetError(txt_AddLine2, "");
            errorProvider_mob.SetError(txt_Mobile, "");
            errorProvider_pass.SetError(txtPassword, "");
            errorProvider_conform.SetError(txtConfirmPassword, "");
            errorProvider_ans.SetError(txt_sec_answer, "");
            errorProvider_qus.SetError(cbx_security_q, "");
            errorProvider_utype.SetError(cbxUserType, "");
            errorProvider_unme.SetError(txtUserName, "");
            errorProvider_email.SetError(txt_Email, "");
            errorProvider_nic.SetError(txt_NIC, "");


            if (txt_FirstName.Text != "" && txt_LastName.Text != "" && txt_Mobile.Text != "" && txt_AddLine1.Text != "" && txt_AddLine2.Text != "" && txtUserName.Text != "" && cbxUserType.Text != "" && cbx_security_q.Text != "" && txt_sec_answer.Text != "" && txt_NIC.Text != "" && txt_Email.Text != "")
            {
                if (reg_email.IsMatch(txt_Email.Text) && reg_NIC.IsMatch(txt_NIC.Text))
                {
                    String         iisql = "SELECT User_Name FROM tbl_UserAccount";
                    SqlDataAdapter iiget = new SqlDataAdapter(iisql, ConnectionDB.Connection());
                    DataTable      iins  = new DataTable();
                    iiget.Fill(iins);
                    for (int ii = 0; ii < iins.Rows.Count; ii++)
                    {
                        string uun = iins.Rows[ii]["User_Name"].ToString();
                        if (uun == txtUserName.Text)
                        {
                            alrady = true;
                        }
                    }

                    String         oiisql = "SELECT User_Name FROM tbl_Admin_Accounts";
                    SqlDataAdapter oiiget = new SqlDataAdapter(oiisql, ConnectionDB.Connection());
                    DataTable      oiins  = new DataTable();
                    oiiget.Fill(oiins);
                    for (int oii = 0; oii < oiins.Rows.Count; oii++)
                    {
                        string ouun = oiins.Rows[oii]["User_Name"].ToString();
                        if (ouun == txtUserName.Text)
                        {
                            alrady = true;
                        }
                    }

                    if (alrady == false)
                    {
                        if (txtPassword.Text == txtConfirmPassword.Text)
                        {
                            if (checkBoxPolicy.Checked == true)
                            {
                                try
                                {
                                    //__________________________________________________________________________________________________________________________________________________________________


                                    DB_Op.insert(txt_FirstName.Text, txt_LastName.Text, txt_NIC.Text, txt_Mobile.Text, txt_AddLine1.Text, txt_AddLine2.Text, txt_Email.Text, DateTime.Now.ToString(), cbxUserType.Text, txtUserName.Text, txtPassword.Text, txtConfirmPassword.Text, cbx_security_q.Text, txt_sec_answer.Text);

                                    //_______________________set sal and target____________________________________________________________________________________________________________________


                                    DB_Op.set_sal_tgt(txtUserName.Text, m_sal, m_targt);

                                    //____________________________________________________________________________________________________________________________________________________________

                                    //_______________________Sat sal Balance______________________________________________________________________________________________________________________

                                    pay_op.Insert_sal_blnce(txtUserName.Text, 0, 0);


                                    //______________________________________________________________________________________________________________________________________________________________
                                    if (MessageBox.Show("Account Created Sussesful.", "Sharp Creations", MessageBoxButtons.OK, MessageBoxIcon.Information) == DialogResult.OK)
                                    {
                                        this.Close();
                                    }
                                    //__________________________________________________________________________________________________________________________________________________________________
                                }
                                catch (Exception) { }
                            }
                            else
                            {
                                toolTip_pas.Show("Plese Acsept Mars Privacy Policy", checkBoxPolicy);
                            }
                        }
                        else
                        {
                            toolTip_pas.Show("Password does not Match", txtConfirmPassword, 1000);
                        }
                    }
                    else
                    {
                        toolTip_unm.Show("User name alrady exits", txtUserName, 1000);
                    }
                }
                else
                {
                    if (!reg_email.IsMatch(txt_Email.Text))
                    {
                        toolTip_mail.Show("Invalid Email Address", txt_Email, 1000);
                    }
                    if (!reg_NIC.IsMatch(txt_NIC.Text))
                    {
                        toolTip_Nic.Show("NIC Number is not correct format", txt_NIC, 1000);
                    }
                }
            }

            else
            {
                if (txt_FirstName.Text == "")
                {
                    errorProvider_fnme.SetError(txt_FirstName, "Enter First Name");
                }
                if (txt_LastName.Text == "")
                {
                    errorProvider_lnme.SetError(txt_LastName, "Enter Last Name");
                }
                if (txt_AddLine1.Text == "")
                {
                    errorProvider_add1.SetError(txt_AddLine1, "Enter Address line 1");
                }
                if (txt_AddLine2.Text == "")
                {
                    errorProvider_add2.SetError(txt_AddLine2, "Enter Address line 2");
                }
                if (txt_Mobile.Text == "")
                {
                    errorProvider_mob.SetError(txt_Mobile, "Enter Mobile");
                }
                if (txtPassword.Text == "")
                {
                    errorProvider_pass.SetError(txtPassword, "Enter Passward");
                }
                if (txtConfirmPassword.Text == "")
                {
                    errorProvider_conform.SetError(txtConfirmPassword, "Conform passward");
                }
                if (txt_sec_answer.Text == "")
                {
                    errorProvider_ans.SetError(txt_sec_answer, "Enter Awnser");
                }
                if (cbx_security_q.Text == "")
                {
                    errorProvider_qus.SetError(cbx_security_q, "Enter Question");
                }
                if (cbxUserType.Text == "")
                {
                    errorProvider_utype.SetError(cbxUserType, "Select user type");
                }
                if (txtUserName.Text == "")
                {
                    errorProvider_unme.SetError(txtUserName, "Enter User Name");
                }
                if (txt_Email.Text == "")
                {
                    errorProvider_email.SetError(txt_Email, "Enter Email");
                }
                if (txt_NIC.Text == "")
                {
                    errorProvider_nic.SetError(txt_NIC, "Enter NIC Number");
                }
            }
        }
        // public static ToolStripMenuItem rpottt = new ToolStripMenuItem();

        private void Main_Load(object sender, EventArgs e)
        {
            logut = false;  rstor = false;



//--------------------------------Close Log_main-----------------------------------//
            for (int index = Application.OpenForms.Count - 1; index >= 0; index--)
            {
                if (Application.OpenForms[1].Name == "Log_main")
                {
                    Application.OpenForms[1].Close();
                }
            }
//---------------------------------------------------------------------------------//
            SqlDataReader owndr = op2.select_owner();

            if (owndr.Read())
            {
                own_un = owndr["User_Name"].ToString();
                if (un == own_un)
                {
                    notifyIcon2.Icon    = SystemIcons.Information;
                    notifyIcon2.Visible = true;
                    notifyIcon2.ShowBalloonTip(2000, "Owner Account", "Welcome to Mars ComputerSystem", ToolTipIcon.Info);
                }
            }



            if (UT1 == "Administrator")
            {
                salaryAndTargrtToolStripMenuItem.Enabled = false;
                receivedSalaryToolStripMenuItem.Enabled  = false;
                ownerAccountToolStripMenuItem.Enabled    = false;
                //backupDatabaseToolStripMenuItem.Enabled = false;
                //restorDatabaseToolStripMenuItem.Enabled = false;
            }
            if (UT1 == "Standard User")
            {
                reportsToolStripMenuItem.Enabled        = false;
                payrollToolStripMenuItem.Enabled        = false;
                employersToolStripMenuItem.Enabled      = false;
                toolStripSplitButton_prol.Enabled       = false;
                toolStripButton9.Enabled                = false;
                backupDatabaseToolStripMenuItem.Enabled = false;
                restorDatabaseToolStripMenuItem.Enabled = false;
            }

            panelMain.Controls.Clear();
            New_invoice addinvoice = new New_invoice(un, UT1);

            addinvoice.TopLevel = false;
            addinvoice.Visible  = true;
            panelMain.Controls.Add(addinvoice);
            p1 = panelMain;



            firstlod = true;

            now_yer = DateTime.Today.Year.ToString();
            now_mon = DateTime.Today.Month.ToString();



            //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++check temp Table is Null++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++//
            String         emty    = "SELECT*FROM tbl_Salary_Temp";
            SqlDataAdapter iigemty = new SqlDataAdapter(emty, ConnectionDB.Connection());
            DataTable      iemty   = new DataTable();

            iigemty.Fill(iemty);
            if (0 == iemty.Rows.Count) // does not exist
            {
                pay_op.Insert_Temp_data(now_yer, now_mon);
            }

            //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

            SqlDataReader tmpdr = pay_op.select_Temp_data();

            if (tmpdr.Read())
            {
                DB_yer = tmpdr["Year"].ToString();
                DB_mon = tmpdr["Month"].ToString();
            }

            if (DB_yer != now_yer || DB_mon != now_mon)
            {
                if (Convert.ToDouble(DB_yer) < Convert.ToDouble(now_yer) || Convert.ToDouble(DB_mon) < Convert.ToDouble(now_mon))
                {
                    if (MessageBox.Show("Accoding System Date Time This Is A New Month \nIf You Sure System Date time Correct Press \"OK\" To Complete Old Month Payroll Details", "Sharp Creation", MessageBoxButtons.OKCancel, MessageBoxIcon.Information) == DialogResult.OK)
                    {
                        //=+=+=+=+=+=+=+=+=  Update payroll  +=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=


                        String         sql = "SELECT*FROM tbl_UserAccount";
                        SqlDataAdapter get = new SqlDataAdapter(sql, ConnectionDB.Connection());
                        DataTable      ns  = new DataTable();
                        get.Fill(ns);
                        for (int i = 0; i < ns.Rows.Count; i++)
                        {
                            string unme = ns.Rows[i]["User_Name"].ToString();
                            // MessageBox.Show(unme);


                            mon_sal  = 0; mon_tgt = 0; arias = 0; reminig = 0; compt_tgt = 0; net_sal = 0; tot_sal = 0; etra_com_tgt = 0; tgt_rte = 0; etra_sal = 0; recevd_sal = 0; rest_sal = 0; additionl_sal = 0;
                            invo_yer = ""; invo_mon = ""; recev_yer = ""; recev_mon = "";

                            SqlDataReader htydr = pay_op.select_sal_tgt(unme);
                            if (htydr.Read())
                            {
                                mon_sal = Convert.ToDecimal(htydr["Monthly_Salary"].ToString());
                                mon_tgt = Convert.ToDecimal(htydr["Monthly_Trget"].ToString());
                            }

                            SqlDataReader blncdr = pay_op.select_sal_blnce(unme);
                            if (blncdr.Read())
                            {
                                arias   = Convert.ToDecimal(blncdr["Arrears"].ToString());
                                reminig = Convert.ToDecimal(blncdr["Remaining"].ToString());
                            }

                            //____________________net month sal__________________________________________________________________________________________

                            net_sal = (mon_sal + reminig) - arias;
                            //___________________________________________________________________________________________________________________________

                            //_______________________________________get completed target_________________________________________________________________

                            String         iisql = "SELECT Invoice_Date,Total_Price FROM tbl_Invoice WHERE Seals_ref='" + unme + "'";
                            SqlDataAdapter iiget = new SqlDataAdapter(iisql, ConnectionDB.Connection());
                            DataTable      iins  = new DataTable();
                            iiget.Fill(iins);
                            for (int ii = 0; ii < iins.Rows.Count; ii++)
                            {
                                decimal invo_tot = Convert.ToDecimal(iins.Rows[ii]["Total_Price"].ToString());
                                invo_dte = Convert.ToDateTime(iins.Rows[ii]["Invoice_Date"].ToString());
                                invo_yer = invo_dte.Year.ToString();
                                invo_mon = invo_dte.Month.ToString();

                                if (DB_yer == invo_yer && DB_mon == invo_mon)
                                {
                                    compt_tgt += invo_tot;
                                }
                            }

                            //_____________________________________________________________________________________________________________________________


                            //_____________________Extra completed_________________________________________________________________________________________

                            if (compt_tgt > mon_tgt)
                            {
                                etra_com_tgt = compt_tgt - mon_tgt;
                            }

                            //_____________________________________________________________________________________________________________________________

                            //_____________________Extra salary _________________________________________________________________________________________

                            SqlDataReader rtedr = pay_op.select_tgt_rte(unme);
                            if (rtedr.Read())
                            {
                                tgt_rte = Convert.ToDecimal(rtedr["Target_rate"].ToString());
                            }

                            etra_sal = (Math.Round(etra_com_tgt) / 100) * tgt_rte;



                            //_____________________________________________________________________________________________________________________________

                            //_____________________Total salary ___________________________________________________________________________________________
                            tot_sal = net_sal + etra_sal;
                            //_____________________________________________________________________________________________________________________________


                            //_______________Received Salary_______________________________________________________________________________________________

                            String         siisql = "SELECT * FROM tbl_Salary_Received WHERE User_Name='" + unme + "'";
                            SqlDataAdapter siiget = new SqlDataAdapter(siisql, ConnectionDB.Connection());
                            DataTable      siins  = new DataTable();
                            siiget.Fill(siins);
                            for (int sii = 0; sii < siins.Rows.Count; sii++)
                            {
                                decimal recevid_tot = Convert.ToDecimal(siins.Rows[sii]["Received_Salary"].ToString());
                                receive_date = Convert.ToDateTime(siins.Rows[sii]["Received_Date"].ToString());
                                recev_yer    = receive_date.Year.ToString();
                                recev_mon    = receive_date.Month.ToString();

                                if (DB_yer == recev_yer && DB_mon == recev_mon)
                                {
                                    recevd_sal += recevid_tot;
                                }
                            }

                            //_____________________________________________________________________________________________________________________________



                            //______________________________Sal_rest_______________________________________________________________________________________

                            if (recevd_sal <= tot_sal)
                            {
                                rest_sal = tot_sal - recevd_sal;
                            }
                            //_____________________________________________________________________________________________________________________________


                            //______________________________Additional received_____________________________________________________________________________
                            if (recevd_sal > tot_sal)
                            {
                                additionl_sal = recevd_sal - tot_sal;
                            }
                            //_____________________________________________________________________________________________________________________________


                            //_________________________Insert sal Histry___________________________________________________________________________________
                            try
                            {
                                pay_op.Insert_sal_history(unme, DB_yer, DB_mon, mon_sal, arias, reminig, net_sal, mon_tgt, compt_tgt, etra_com_tgt, etra_sal, tot_sal, recevd_sal, additionl_sal, rest_sal);
                            }
                            catch (Exception) { }



                            //_____________________________________________________________________________________________________________________________

                            //_________________________Update sal Balance___________________________________________________________________________________
                            try
                            {
                                pay_op.Update_sal_blnce(unme, additionl_sal, rest_sal);
                            }
                            catch (Exception) { }
                            //_____________________________________________________________________________________________________________________________
                        }

                        //______________________Update temp data_______________________________________________________________________________________
                        try
                        {
                            pay_op.Update_temp_data(now_yer, now_mon);
                        }
                        catch (Exception) { }

                        //______________________________________________________________________________________________________________________________


                        //=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=
                        notifyIcon1.Icon    = SystemIcons.Information;
                        notifyIcon1.Visible = true;
                        notifyIcon1.ShowBalloonTip(2000, "Sharp Creation", "\"" + DB_yer + " / " + DB_mon + " \"  Payroll Details Completed Sucessfully.\nAnd Start New Payroll " + "\"" + now_yer + " / " + now_mon + " \"", ToolTipIcon.Info);
                    }
                }
                else
                {
                    MessageBox.Show("Your System Date is Wrong", "Sharp Creatuon", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }
            }


            // rpottt = reportsToolStripMenuItem;

            logoutToolStripMenuItem.Font = new Font(Font, Font.Style | FontStyle.Regular);
        }
        private void cbx_usernn_SelectedIndexChanged(object sender, EventArgs e)
        {
            mon_sal  = 0; mon_tgt = 0; arias = 0; reminig = 0; compt_tgt = 0; net_sal = 0; tot_sal = 0; etra_com_tgt = 0; tgt_rte = 0; etra_sal = 0; recevd_sal = 0; rest_sal = 0; additionl_sal = 0;
            invo_yer = ""; invo_mon = ""; recev_yer = ""; recev_mon = "";

            SqlDataReader usdr = pay_op.select_User_Acc(cbx_usernn.Text);

            if (usdr.Read())
            {
                lbl_fulnm.Text = usdr["First_Name"].ToString() + " " + usdr["Last_Name"].ToString() + " , " + usdr["Address_Line1"].ToString() + " " + usdr["Address_Line2"].ToString();;
            }

            SqlDataReader htydr = pay_op.select_sal_tgt(cbx_usernn.Text);

            if (htydr.Read())
            {
                mon_sal = Convert.ToDecimal(htydr["Monthly_Salary"].ToString());
                mon_tgt = Convert.ToDecimal(htydr["Monthly_Trget"].ToString());
            }

            SqlDataReader blncdr = pay_op.select_sal_blnce(cbx_usernn.Text);

            if (blncdr.Read())
            {
                arias   = Convert.ToDecimal(blncdr["Arrears"].ToString());
                reminig = Convert.ToDecimal(blncdr["Remaining"].ToString());
            }

//____________________net month sal__________________________________________________________________________________________

            net_sal = (mon_sal + reminig) - arias;
//___________________________________________________________________________________________________________________________



//_______________________________________get completed target_________________________________________________________________

            String         iisql = "SELECT Invoice_Date,Total_Price FROM tbl_Invoice WHERE Seals_ref='" + cbx_usernn.Text + "'";
            SqlDataAdapter iiget = new SqlDataAdapter(iisql, ConnectionDB.Connection());
            DataTable      iins  = new DataTable();

            iiget.Fill(iins);
            for (int ii = 0; ii < iins.Rows.Count; ii++)
            {
                decimal invo_tot = Convert.ToDecimal(iins.Rows[ii]["Total_Price"].ToString());
                invo_dte = Convert.ToDateTime(iins.Rows[ii]["Invoice_Date"].ToString());
                invo_yer = invo_dte.Year.ToString();
                invo_mon = invo_dte.Month.ToString();

                if (DB_yer == invo_yer && DB_mon == invo_mon)
                {
                    compt_tgt += invo_tot;
                }
            }

//_____________________________________________________________________________________________________________________________



//_____________________Extra completed_________________________________________________________________________________________

            if (compt_tgt > mon_tgt)
            {
                etra_com_tgt = compt_tgt - mon_tgt;
            }

//_____________________________________________________________________________________________________________________________

//_____________________Extra salary _________________________________________________________________________________________

            SqlDataReader rtedr = pay_op.select_tgt_rte(cbx_usernn.Text);

            if (rtedr.Read())
            {
                tgt_rte = Convert.ToDecimal(rtedr["Target_rate"].ToString());
            }



            etra_sal = Math.Round((etra_com_tgt / 100) * tgt_rte, 2);



//_____________________________________________________________________________________________________________________________

//_____________________Total salary ___________________________________________________________________________________________
            tot_sal = net_sal + etra_sal;
//_____________________________________________________________________________________________________________________________


            //_______________Received Salary_______________________________________________________________________________________________

            String         siisql = "SELECT * FROM tbl_Salary_Received WHERE User_Name='" + cbx_usernn.Text + "'";
            SqlDataAdapter siiget = new SqlDataAdapter(siisql, ConnectionDB.Connection());
            DataTable      siins  = new DataTable();

            siiget.Fill(siins);
            for (int sii = 0; sii < siins.Rows.Count; sii++)
            {
                decimal recevid_tot = Convert.ToDecimal(siins.Rows[sii]["Received_Salary"].ToString());
                receive_date = Convert.ToDateTime(siins.Rows[sii]["Received_Date"].ToString());
                recev_yer    = receive_date.Year.ToString();
                recev_mon    = receive_date.Month.ToString();

                if (DB_yer == recev_yer && DB_mon == recev_mon)
                {
                    recevd_sal += recevid_tot;
                }
            }

            //_____________________________________________________________________________________________________________________________



            //______________________________Sal_rest_______________________________________________________________________________________

            if (recevd_sal <= tot_sal)
            {
                rest_sal = tot_sal - recevd_sal;
            }
            //_____________________________________________________________________________________________________________________________


            //______________________________Additional received_____________________________________________________________________________
            if (recevd_sal > tot_sal)
            {
                additionl_sal = recevd_sal - tot_sal;
            }
            //_____________________________________________________________________________________________________________________________

            //________________________Lable Display_________________________________________________________________________________________

            lbl_mon_sal.Text          = mon_sal.ToString();
            lbl_mon_tgt.Text          = mon_tgt.ToString();
            lbl_reming.Text           = reminig.ToString();
            lbl_arias.Text            = arias.ToString();
            lbl_net_sal.Text          = net_sal.ToString();
            lbl_com_tgt.Text          = compt_tgt.ToString();
            lbl_extr_com_tgt.Text     = etra_com_tgt.ToString();
            lbl_etra_sal.Text         = etra_sal.ToString();
            lbl_tot_sal.Text          = tot_sal.ToString();
            lbl_totsal1.Text          = tot_sal.ToString();
            lbl_recevd_sal.Text       = recevd_sal.ToString();
            lbl_sal_rest.Text         = rest_sal.ToString();
            lbl_aditionl_receved.Text = additionl_sal.ToString();

            //_____________________________________________________________________________________________________________________________
        }
Exemplo n.º 7
0
        private void cbx_usernn_SelectedIndexChanged(object sender, EventArgs e)
        {
            mon_sal  = 0; mon_tgt = 0; arias = 0; reminig = 0; compt_tgt = 0; net_sal = 0; tot_sal = 0; etra_com_tgt = 0; tgt_rte = 0; etra_sal = 0; recevd_sal = 0; rest_sal = 0; additionl_sal = 0;
            invo_yer = ""; invo_mon = ""; recev_yer = ""; recev_mon = "";



            string         sql = "SELECT * FROM tbl_Salary_Received WHERE Month='" + DB_mon + "'";
            SqlDataAdapter da  = new SqlDataAdapter(sql, ConnectionDB.Connection());

            dtbl = new DataTable();
            da.Fill(dtbl);
            BindingSource bnsue = new BindingSource();

            bnsue.DataSource         = dtbl;
            dgv_get_Month.DataSource = bnsue;
            da.Update(dtbl);

            DataView dv = new DataView(dtbl);

            dv.RowFilter             = "User_Name like '%" + cbx_usernn.Text + "%' ";
            dgv_get_Month.DataSource = dv;


//______________________________________________________________________________________________________________________________
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

            SqlDataReader htydr = pay_op.select_sal_tgt(cbx_usernn.Text);

            if (htydr.Read())
            {
                mon_sal = Convert.ToDecimal(htydr["Monthly_Salary"].ToString());
                mon_tgt = Convert.ToDecimal(htydr["Monthly_Trget"].ToString());
            }

            SqlDataReader blncdr = pay_op.select_sal_blnce(cbx_usernn.Text);

            if (blncdr.Read())
            {
                arias   = Convert.ToDecimal(blncdr["Arrears"].ToString());
                reminig = Convert.ToDecimal(blncdr["Remaining"].ToString());
            }

            //____________________net month sal__________________________________________________________________________________________

            net_sal = (mon_sal + reminig) - arias;
            //___________________________________________________________________________________________________________________________



            //_______________________________________get completed target_________________________________________________________________

            String         iisql = "SELECT Invoice_Date,Total_Price FROM tbl_Invoice WHERE Seals_ref='" + cbx_usernn.Text + "'";
            SqlDataAdapter iiget = new SqlDataAdapter(iisql, ConnectionDB.Connection());
            DataTable      iins  = new DataTable();

            iiget.Fill(iins);
            for (int ii = 0; ii < iins.Rows.Count; ii++)
            {
                decimal invo_tot = Convert.ToDecimal(iins.Rows[ii]["Total_Price"].ToString());
                invo_dte = Convert.ToDateTime(iins.Rows[ii]["Invoice_Date"].ToString());
                invo_yer = invo_dte.Year.ToString();
                invo_mon = invo_dte.Month.ToString();

                if (DB_yer == invo_yer && DB_mon == invo_mon)
                {
                    compt_tgt += invo_tot;
                }
            }

            //_____________________________________________________________________________________________________________________________



            //_____________________Extra completed_________________________________________________________________________________________

            if (compt_tgt > mon_tgt)
            {
                etra_com_tgt = compt_tgt - mon_tgt;
            }

            //_____________________________________________________________________________________________________________________________

            //_____________________Extra salary _________________________________________________________________________________________

            SqlDataReader rtedr = pay_op.select_tgt_rte(cbx_usernn.Text);

            if (rtedr.Read())
            {
                tgt_rte = Convert.ToDecimal(rtedr["Target_rate"].ToString());
            }



            etra_sal = Math.Round((etra_com_tgt / 100) * tgt_rte, 2);



            //_____________________________________________________________________________________________________________________________

            //_____________________Total salary ___________________________________________________________________________________________
            tot_sal = net_sal + etra_sal;
            //_____________________________________________________________________________________________________________________________


            //_______________Received Salary_______________________________________________________________________________________________

            String         siisql = "SELECT * FROM tbl_Salary_Received WHERE User_Name='" + cbx_usernn.Text + "'";
            SqlDataAdapter siiget = new SqlDataAdapter(siisql, ConnectionDB.Connection());
            DataTable      siins  = new DataTable();

            siiget.Fill(siins);
            for (int sii = 0; sii < siins.Rows.Count; sii++)
            {
                decimal recevid_tot = Convert.ToDecimal(siins.Rows[sii]["Received_Salary"].ToString());
                receive_date = Convert.ToDateTime(siins.Rows[sii]["Received_Date"].ToString());
                recev_yer    = receive_date.Year.ToString();
                recev_mon    = receive_date.Month.ToString();

                if (DB_yer == recev_yer && DB_mon == recev_mon)
                {
                    recevd_sal += recevid_tot;
                }
            }

            //_____________________________________________________________________________________________________________________________



            //______________________________Sal_rest_______________________________________________________________________________________

            if (recevd_sal <= tot_sal)
            {
                rest_sal = tot_sal - recevd_sal;
            }
            //_____________________________________________________________________________________________________________________________


            //______________________________Additional received_____________________________________________________________________________
            if (recevd_sal > tot_sal)
            {
                additionl_sal = recevd_sal - tot_sal;
            }
            //_____________________________________________________________________________________________________________________________



            lbl_tot_sal.Text        = tot_sal.ToString();
            lbl_recevd_sal.Text     = recevd_sal.ToString();
            lbl_sal_rest.Text       = rest_sal.ToString();
            lbl_aditionl_reced.Text = additionl_sal.ToString();



//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
//___________________________________________________________________________________________________________________________
        }
Exemplo n.º 8
0
        private void Edti_Items_Load(object sender, EventArgs e)
        {
            lbl_itemNo.Text              = itup.no;
            txtAddItemBarcode.Text       = itup.barcode;
            txtAddItemDiscription.Text   = itup.discrip;
            txtAddItemItemName.Text      = itup.name;
            txtAddItemPurchasePrice.Text = itup.purchPiz;
            txtAddItemSalesPrice.Text    = itup.selsPiz;
            txtAddItemSerial.Text        = itup.serial;
            txtAddItemTaxRate.Text       = itup.tax;
            cbxAddItemBrande.Text        = itup.Brande;
            cbxAddItemCatogory.Text      = itup.catogy;
            cbxAddItemItemType.Text      = itup.typ;
            cbxAddItemSubCatogory.Text   = itup.subCatogy;
            cbxAddItemSupplier.Text      = itup.supp;

            if (itup.wranty != "No Warranty")
            {
                string   wrny   = itup.wranty;
                string[] warray = wrny.Split(' ');
                string   wtyNo  = warray[0].ToString();
                string   wtyDu  = warray[1].ToString();

                cb_warnty.Checked      = true;
                cbx_wrty_number.Text   = wtyNo;
                cbx_wrty_duretion.Text = wtyDu;
            }
            else
            {
                cbx_wrty_number.Enabled   = false;
                cbx_wrty_duretion.Enabled = false;
            }



            String         sql = "SELECT*FROM tbl_AddS_Supplier";
            SqlDataAdapter get = new SqlDataAdapter(sql, ConnectionDB.Connection());
            DataTable      ns  = new DataTable();

            get.Fill(ns);
            for (int i = 0; i < ns.Rows.Count; i++)
            {
                cbxAddItemSupplier.Items.Add(ns.Rows[i]["Business_Name"]);
            }


            String         csql = "SELECT*FROM tbl_catogory";
            SqlDataAdapter cget = new SqlDataAdapter(csql, ConnectionDB.Connection());
            DataTable      cdt  = new DataTable();

            cget.Fill(cdt);
            for (int i = 0; i < cdt.Rows.Count; i++)
            {
                cbxAddItemCatogory.Items.Add(cdt.Rows[i]["catogory"]);
            }


            //String scsql = "SELECT*FROM tbl_sub_catogory";
            //SqlDataAdapter scget = new SqlDataAdapter(scsql, ConnectionDB.Connection());
            //DataTable scdt = new DataTable();
            //scget.Fill(scdt);
            //for (int i = 0; i < scdt.Rows.Count; i++)
            //{
            //    cbxAddItemSubCatogory.Items.Add(scdt.Rows[i]["sub_catogory"]);
            //}


            String         bsql = "SELECT*FROM tbl_brande";
            SqlDataAdapter bget = new SqlDataAdapter(bsql, ConnectionDB.Connection());
            DataTable      bdt  = new DataTable();

            bget.Fill(bdt);
            for (int i = 0; i < bdt.Rows.Count; i++)
            {
                cbxAddItemBrande.Items.Add(bdt.Rows[i]["Brande"]);
            }



            String         tsql = "SELECT*FROM tbl_itype";
            SqlDataAdapter tget = new SqlDataAdapter(tsql, ConnectionDB.Connection());
            DataTable      tdt  = new DataTable();

            tget.Fill(tdt);
            for (int i = 0; i < tdt.Rows.Count; i++)
            {
                cbxAddItemItemType.Items.Add(tdt.Rows[i]["Item_type"]);
            }


            cbxAddItemCatogory.DropDownStyle      = System.Windows.Forms.ComboBoxStyle.DropDown;
            cbxAddItemCatogory.AutoCompleteMode   = AutoCompleteMode.SuggestAppend;
            cbxAddItemCatogory.AutoCompleteSource = AutoCompleteSource.ListItems;

            cbxAddItemBrande.DropDownStyle      = System.Windows.Forms.ComboBoxStyle.DropDown;
            cbxAddItemBrande.AutoCompleteMode   = AutoCompleteMode.SuggestAppend;
            cbxAddItemBrande.AutoCompleteSource = AutoCompleteSource.ListItems;
        }
        private void button1_Click(object sender, EventArgs e)
        {
            ep_iname.SetError(txtAddItemItemName, "");
            ep_isalePrz.SetError(txtAddItemSalesPrice, "");
            ep_ipuchsPriz.SetError(lbl_p_piz, "");
            ep_isupp.SetError(cbxAddItemSupplier, "");
            ep_ictogry.SetError(cbxAddItemCatogory, "");
            ep_isubCotory.SetError(cbxAddItemSubCatogory, "");
            ep_ibrnd.SetError(cbxAddItemBrande, "");
            tp_required.Show("", btnAddItemAddItem, 5000);

            //-----------------clear all textbox.text-----------------------
            Action <Control.ControlCollection> func = null;

            func = (controls) =>
            {
                foreach (Control control in controls)
                {
                    if (control is TextBox)
                    {
                        (control as TextBox).Clear();
                    }
                    else
                    {
                        func(control.Controls);
                    }
                }
            };
            func(Controls);

            cbxAddItemBrande.Text      = "";
            cbxAddItemCatogory.Text    = "";
            cbxAddItemSubCatogory.Text = "";
            cbxAddItemSupplier.Text    = "";
            cbxAddItemItemType.Text    = "";



            string rNo = itemdb.Itemno();

            string        sql = "SELECT * FROM tbl_Add_Items WHERE Item_No='" + rNo + "'";
            SqlCommand    com = new SqlCommand(sql, ConnectionDB.Connection());
            SqlDataReader dr  = com.ExecuteReader();

            if (dr.Read())
            {
                string itName     = dr["Item_Name"].ToString();
                string itSelspriz = dr["Sales_Price"].ToString();
                string itPurpriz  = dr["Purchase_Price"].ToString();
                string itSupp     = dr["Supplier"].ToString();
                string itTax      = dr["Tax_Rate"].ToString();
                string itCtgry    = dr["Catogory"].ToString();
                string itSubctgry = dr["Sub_Catogory"].ToString();
                string itBrnd     = dr["Brande"].ToString();
                string itType     = dr["Item_Type"].ToString();
                string itDiscp    = dr["Discription"].ToString();

                if (dr["Warranty"].ToString() != "No Warranty")
                {
                    string   wrny   = dr["Warranty"].ToString();
                    string[] warray = wrny.Split(' ');
                    string   wtyNo  = warray[0].ToString();
                    string   wtyDu  = warray[1].ToString();


                    cbx_wrty_number.Text   = "";
                    cbx_wrty_duretion.Text = "";
                    cb_warnty.Checked      = true;
                    cbx_wrty_number.Text   = wtyNo;
                    cbx_wrty_duretion.Text = wtyDu;
                }
                else
                {
                    cbx_wrty_number.Enabled   = false;
                    cbx_wrty_duretion.Enabled = false;
                    cb_warnty.Checked         = false;
                }



                txtAddItemItemName.Text    = itName;
                txtAddItemSalesPrice.Text  = itSelspriz;
                lbl_p_piz.Text             = itPurpriz;
                txtAddItemTaxRate.Text     = itTax;
                txtAddItemDiscription.Text = itDiscp;
                cbxAddItemBrande.Text      = itBrnd;
                cbxAddItemCatogory.Text    = itCtgry;
                cbxAddItemSubCatogory.Text = itSubctgry;
                cbxAddItemSupplier.Text    = itSupp;
                cbxAddItemItemType.Text    = itType;
            }

            txtAddItemBarcode.Focus();
        }
Exemplo n.º 10
0
        private void button1_Click(object sender, EventArgs e)
        {
            if (cbx_usernn.Text != "" && txt_getSal.Text != "")
            {
                try
                {
                    pay_op.Insert_Received_Salary(cbx_usernn.Text, Convert.ToDecimal(txt_getSal.Text), DateTime.Now, now_yer, now_mon);
                    MessageBox.Show("\"" + cbx_usernn.Text + "\"  Received \"Rs." + txt_getSal.Text + "\"" + " Sucessfully", "Sharp Creation", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
                catch (Exception) { }


                DataSet rds = pay_op.user_receved_sal(cbx_usernn.Text, now_yer, now_mon);
                dgv_get_Month.DataSource = rds.Tables["tbl_Salary_Received"];



                //______________________________________________________________________________________________________________________________
                //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++


                mon_sal  = 0; mon_tgt = 0; arias = 0; reminig = 0; compt_tgt = 0; net_sal = 0; tot_sal = 0; etra_com_tgt = 0; tgt_rte = 0; etra_sal = 0; recevd_sal = 0; rest_sal = 0; additionl_sal = 0;
                invo_yer = ""; invo_mon = ""; recev_yer = ""; recev_mon = "";


                SqlDataReader htydr = pay_op.select_sal_tgt(cbx_usernn.Text);
                if (htydr.Read())
                {
                    mon_sal = Convert.ToDecimal(htydr["Monthly_Salary"].ToString());
                    mon_tgt = Convert.ToDecimal(htydr["Monthly_Trget"].ToString());
                }

                SqlDataReader blncdr = pay_op.select_sal_blnce(cbx_usernn.Text);
                if (blncdr.Read())
                {
                    arias   = Convert.ToDecimal(blncdr["Arrears"].ToString());
                    reminig = Convert.ToDecimal(blncdr["Remaining"].ToString());
                }

                //____________________net month sal__________________________________________________________________________________________

                net_sal = (mon_sal + reminig) - arias;
                //___________________________________________________________________________________________________________________________



                //_______________________________________get completed target_________________________________________________________________

                String         iisql = "SELECT Invoice_Date,Total_Price FROM tbl_Invoice WHERE Seals_ref='" + cbx_usernn.Text + "'";
                SqlDataAdapter iiget = new SqlDataAdapter(iisql, ConnectionDB.Connection());
                DataTable      iins  = new DataTable();
                iiget.Fill(iins);
                for (int ii = 0; ii < iins.Rows.Count; ii++)
                {
                    decimal invo_tot = Convert.ToDecimal(iins.Rows[ii]["Total_Price"].ToString());
                    invo_dte = Convert.ToDateTime(iins.Rows[ii]["Invoice_Date"].ToString());
                    invo_yer = invo_dte.Year.ToString();
                    invo_mon = invo_dte.Month.ToString();

                    if (DB_yer == invo_yer && DB_mon == invo_mon)
                    {
                        compt_tgt += invo_tot;
                    }
                }

                //_____________________________________________________________________________________________________________________________



                //_____________________Extra completed_________________________________________________________________________________________

                if (compt_tgt > mon_tgt)
                {
                    etra_com_tgt = compt_tgt - mon_tgt;
                }

                //_____________________________________________________________________________________________________________________________

                //_____________________Extra salary _________________________________________________________________________________________

                SqlDataReader rtedr = pay_op.select_tgt_rte(cbx_usernn.Text);
                if (rtedr.Read())
                {
                    tgt_rte = Convert.ToDecimal(rtedr["Target_rate"].ToString());
                }



                etra_sal = (Math.Round(etra_com_tgt) / 100) * tgt_rte;



                //_____________________________________________________________________________________________________________________________

                //_____________________Total salary ___________________________________________________________________________________________
                tot_sal = net_sal + etra_sal;
                //_____________________________________________________________________________________________________________________________


                //_______________Received Salary_______________________________________________________________________________________________

                String         siisql = "SELECT * FROM tbl_Salary_Received WHERE User_Name='" + cbx_usernn.Text + "'";
                SqlDataAdapter siiget = new SqlDataAdapter(siisql, ConnectionDB.Connection());
                DataTable      siins  = new DataTable();
                siiget.Fill(siins);
                for (int sii = 0; sii < siins.Rows.Count; sii++)
                {
                    decimal recevid_tot = Convert.ToDecimal(siins.Rows[sii]["Received_Salary"].ToString());
                    receive_date = Convert.ToDateTime(siins.Rows[sii]["Received_Date"].ToString());
                    recev_yer    = receive_date.Year.ToString();
                    recev_mon    = receive_date.Month.ToString();

                    if (DB_yer == recev_yer && DB_mon == recev_mon)
                    {
                        recevd_sal += recevid_tot;
                    }
                }

                //_____________________________________________________________________________________________________________________________



                //______________________________Sal_rest_______________________________________________________________________________________

                if (recevd_sal <= tot_sal)
                {
                    rest_sal = tot_sal - recevd_sal;
                }
                //_____________________________________________________________________________________________________________________________


                //______________________________Additional received_____________________________________________________________________________
                if (recevd_sal > tot_sal)
                {
                    additionl_sal = recevd_sal - tot_sal;
                }
                //_____________________________________________________________________________________________________________________________



                lbl_tot_sal.Text        = tot_sal.ToString();
                lbl_recevd_sal.Text     = recevd_sal.ToString();
                lbl_sal_rest.Text       = rest_sal.ToString();
                lbl_aditionl_reced.Text = additionl_sal.ToString();



                //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
                //___________________________________________________________________________________________________________________________


                txt_getSal.Clear();
            }
            else
            {
                if (cbx_usernn.Text == "")
                {
                    toolTip1.Show("Select User name", cbx_usernn, 1000);
                }
                if (txt_getSal.Text == "")
                {
                    toolTip2.Show("Enter Value", txt_getSal, 1000);
                }
            }
        }
        private void Add_Items_Load(object sender, EventArgs e)
        {
            tx_brcde = txtAddItemBarcode;


//==================================================From Item Table==========================================================//
            string rNo = itemdb.Itemno();

            if (rNo.Equals("") || rNo == null)
            {
                iNo = 001000;
            }
            else
            {
                iNo = Convert.ToInt32(rNo);
                iNo = iNo + 1;
                //MessageBox.Show(iNo.ToString());
            }

//==============================================================================================================================//

            string rcNo = itemdb.getCusno();

            if (rcNo.Equals("") || rcNo == null)
            {
                cNo = 001000;
            }
            else
            {
                cNo = Convert.ToInt32(rcNo);
                cNo = cNo + 1;
                //MessageBox.Show(cNo.ToString());
            }



            int[] numbers = new[] { iNo, cNo };

            int max = numbers.Max();

            lbl_itemNo.Text = Convert.ToString(max);



            String         sql = "SELECT*FROM tbl_AddS_Supplier";
            SqlDataAdapter get = new SqlDataAdapter(sql, ConnectionDB.Connection());
            DataTable      ns  = new DataTable();

            get.Fill(ns);
            for (int i = 0; i < ns.Rows.Count; i++)
            {
                cbxAddItemSupplier.Items.Add(ns.Rows[i]["Business_Name"]);
            }


            String         csql = "SELECT*FROM tbl_catogory";
            SqlDataAdapter cget = new SqlDataAdapter(csql, ConnectionDB.Connection());
            DataTable      cdt  = new DataTable();

            cget.Fill(cdt);
            for (int i = 0; i < cdt.Rows.Count; i++)
            {
                cbxAddItemCatogory.Items.Add(cdt.Rows[i]["catogory"]);
            }


            //String scsql = "SELECT*FROM tbl_sub_catogory";
            //SqlDataAdapter scget = new SqlDataAdapter(scsql, ConnectionDB.Connection());
            //DataTable scdt = new DataTable();
            //scget.Fill(scdt);
            //for (int i = 0; i < scdt.Rows.Count; i++)
            //{
            //    cbxAddItemSubCatogory.Items.Add(scdt.Rows[i]["sub_catogory"]);
            //}


            String         bsql = "SELECT*FROM tbl_brande";
            SqlDataAdapter bget = new SqlDataAdapter(bsql, ConnectionDB.Connection());
            DataTable      bdt  = new DataTable();

            bget.Fill(bdt);
            for (int i = 0; i < bdt.Rows.Count; i++)
            {
                cbxAddItemBrande.Items.Add(bdt.Rows[i]["Brande"]);
            }



            String         tsql = "SELECT*FROM tbl_itype";
            SqlDataAdapter tget = new SqlDataAdapter(tsql, ConnectionDB.Connection());
            DataTable      tdt  = new DataTable();

            tget.Fill(tdt);
            for (int i = 0; i < tdt.Rows.Count; i++)
            {
                cbxAddItemItemType.Items.Add(tdt.Rows[i]["Item_type"]);
            }


            tp_ad_details.Show("Add Catogaty, Subcatogary, Brande, Type", btn_add_details, 5000);



            cbxAddItemCatogory.DropDownStyle      = System.Windows.Forms.ComboBoxStyle.DropDown;
            cbxAddItemCatogory.AutoCompleteMode   = AutoCompleteMode.SuggestAppend;
            cbxAddItemCatogory.AutoCompleteSource = AutoCompleteSource.ListItems;



            cbxAddItemBrande.DropDownStyle      = System.Windows.Forms.ComboBoxStyle.DropDown;
            cbxAddItemBrande.AutoCompleteMode   = AutoCompleteMode.SuggestAppend;
            cbxAddItemBrande.AutoCompleteSource = AutoCompleteSource.ListItems;
        }
Exemplo n.º 12
0
        private void txt_Search_TextChanged(object sender, EventArgs e)
        {
            chose = cbx_choose.SelectedItem.ToString();

            if (chose == "Catogory")
            {
                string         sql = "SELECT * FROM tbl_catogory";
                SqlDataAdapter da  = new SqlDataAdapter(sql, ConnectionDB.Connection());
                dtbl = new DataTable();
                da.Fill(dtbl);
                BindingSource bnsue = new BindingSource();
                bnsue.DataSource            = dtbl;
                dgv_item_details.DataSource = bnsue;
                da.Update(dtbl);

                DataView dv = new DataView(dtbl);
                dv.RowFilter = "catogory like '%" + txt_Search.Text + "%' ";
                dgv_item_details.DataSource = dv;
            }

            if (chose == "Sub catogory")
            {
                string         sql = "SELECT * FROM tbl_sub_catogory";
                SqlDataAdapter da  = new SqlDataAdapter(sql, ConnectionDB.Connection());
                dtbl = new DataTable();
                da.Fill(dtbl);
                BindingSource bnsue = new BindingSource();
                bnsue.DataSource            = dtbl;
                dgv_item_details.DataSource = bnsue;
                da.Update(dtbl);

                DataView dv = new DataView(dtbl);
                dv.RowFilter = "sub_catogory like '%" + txt_Search.Text + "%' ";
                dgv_item_details.DataSource = dv;
            }


            if (chose == "Brande")
            {
                string         sql = "SELECT * FROM tbl_brande";
                SqlDataAdapter da  = new SqlDataAdapter(sql, ConnectionDB.Connection());
                dtbl = new DataTable();
                da.Fill(dtbl);
                BindingSource bnsue = new BindingSource();
                bnsue.DataSource            = dtbl;
                dgv_item_details.DataSource = bnsue;
                da.Update(dtbl);

                DataView dv = new DataView(dtbl);
                dv.RowFilter = "Brande like '%" + txt_Search.Text + "%' ";
                dgv_item_details.DataSource = dv;
            }

            if (chose == "Item type")
            {
                string         sql = "SELECT * FROM tbl_itype";
                SqlDataAdapter da  = new SqlDataAdapter(sql, ConnectionDB.Connection());
                dtbl = new DataTable();
                da.Fill(dtbl);
                BindingSource bnsue = new BindingSource();
                bnsue.DataSource            = dtbl;
                dgv_item_details.DataSource = bnsue;
                da.Update(dtbl);

                DataView dv = new DataView(dtbl);
                dv.RowFilter = "Item_type like '%" + txt_Search.Text + "%' ";
                dgv_item_details.DataSource = dv;
            }
        }
        private void btn_print_Click(object sender, EventArgs e)
        {
            try
            {
                invoNo = dgv_Invoice.CurrentRow.Cells["Invoice_No"].Value.ToString();
                SqlDataReader iddr = Invo.select_invoNo(invoNo);
                if (iddr.Read())
                {
                    invodate = Convert.ToDateTime(iddr["Invoice_Date"].ToString());
                    total    = iddr["Total_Price"].ToString();
                    paid     = iddr["Paid_Price"].ToString();
                    blnc     = iddr["Balance"].ToString();
                    cusnom   = iddr["Coustomer_No"].ToString();
                    paymethd = iddr["Payment_Method"].ToString();
                    grantota = iddr["Grande_total"].ToString();
                    disc     = iddr["Discount"].ToString();
                    tax      = iddr["Tax"].ToString();
                }

                SqlDataReader drcus = Invo.select_incus(cusnom);
                if (drcus.Read())
                {
                    fname = drcus["First_Name"].ToString();
                    lnme  = drcus["Last_Name"].ToString();
                    add1  = drcus["Address_Line1"].ToString();
                    add2  = drcus["Address_Line2"].ToString();
                    mobl  = drcus["Mobile"].ToString();
                }
                else
                {
                    fname = "N/A";
                    lnme  = "N/A";
                    add1  = "N/A";
                    add2  = "N/A";
                    mobl  = "N/A";
                }



                String         ibsql = "SELECT*FROM tbl_Invoice_details WHERE Invoice_No='" + invoNo + "'";
                SqlDataAdapter ibget = new SqlDataAdapter(ibsql, ConnectionDB.Connection());
                DataTable      ibns  = new DataTable();
                ibget.Fill(ibns);
                for (int ib = 0; ib < ibns.Rows.Count; ib++)
                {
                    itmno      = ibns.Rows[ib]["Item_No"].ToString();
                    itmNme     = ibns.Rows[ib]["Item_Name"].ToString();
                    itmseril   = ibns.Rows[ib]["Serial_No"].ToString();
                    itsalepriz = ibns.Rows[ib]["Sales_Price"].ToString();
                    itmctgy    = ibns.Rows[ib]["Catogory"].ToString();
                    itmsbctgy  = ibns.Rows[ib]["Sub_Catogory"].ToString();
                    itmbrnd    = ibns.Rows[ib]["Brande"].ToString();
                    itmwarrty  = ibns.Rows[ib]["Warranty"].ToString();
                    iqty       = ibns.Rows[ib]["Quntity"].ToString();



                    //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ check- is bill table Null...? ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++//
                    String         emty_ibl    = "SELECT*FROM tbl_Invoice_bill";
                    SqlDataAdapter iigemty_bil = new SqlDataAdapter(emty_ibl, ConnectionDB.Connection());
                    DataTable      iemty_bil   = new DataTable();
                    iigemty_bil.Fill(iemty_bil);
                    if (0 != iemty_bil.Rows.Count) // does not exist
                    {
                        //___________________________________________________________________________________________________________________________
                        SqlDataReader slct_billDR = Invo.select_invtmp_bil(itmctgy, itmsbctgy, itmbrnd);
                        if (slct_billDR.Read())
                        {
                            string bsril, bqtyy, u_piz; decimal n_qty;

                            bsril = slct_billDR["Serial_No"].ToString();
                            bqtyy = slct_billDR["Quantity"].ToString();
                            u_piz = slct_billDR["Unit_Price"].ToString();
                            n_qty = Convert.ToDecimal(bqtyy) + Convert.ToDecimal(iqty);

                            Invo.Updte_invc_bill(itmctgy, itmsbctgy, itmbrnd, n_qty, (Convert.ToDecimal(u_piz) * n_qty), bsril + "," + itmseril);
                            //MessageBox.Show("update_Dtail");
                        }
                        else
                        {
                            try
                            {
                                Invo.insert_Invoice_Bill(invoNo, invodate, fname + " " + lnme, add1 + " " + add2, mobl, Convert.ToDecimal(grantota), Convert.ToDecimal(disc), Convert.ToDecimal(tax), Convert.ToDecimal(total), Convert.ToDecimal(paid), paymethd, Convert.ToDecimal(blnc), itmseril, itmctgy, itmsbctgy, itmbrnd, itmbrnd + " " + itmNme + " " + itmctgy + " " + itmsbctgy + " \nWarranty- " + itmwarrty, Convert.ToDecimal(Convert.ToDecimal(itsalepriz) / Convert.ToDecimal(iqty)), Convert.ToDecimal(iqty), Convert.ToDecimal(itsalepriz));

                                //MessageBox.Show("Invoice bill add");
                            }
                            catch (Exception ex)
                            { MessageBox.Show(ex.Message); }
                        }

                        //___________________________________________________________________________________________________________________________
                    }
                    else
                    {
                        try
                        {
                            Invo.insert_Invoice_Bill(invoNo, invodate, fname + " " + lnme, add1 + " " + add2, mobl, Convert.ToDecimal(grantota), Convert.ToDecimal(disc), Convert.ToDecimal(tax), Convert.ToDecimal(total), Convert.ToDecimal(paid), paymethd, Convert.ToDecimal(blnc), itmseril, itmctgy, itmsbctgy, itmbrnd, itmbrnd + " " + itmNme + " " + itmctgy + " " + itmsbctgy + " \nWarranty- " + itmwarrty, Convert.ToDecimal(Convert.ToDecimal(itsalepriz) / Convert.ToDecimal(iqty)), Convert.ToDecimal(iqty), Convert.ToDecimal(itsalepriz));

                            //MessageBox.Show("Invoice bill add");
                        }
                        catch (Exception ex)
                        { MessageBox.Show(ex.Message); }
                    }
                }

                Bill invoBil = new Bill();
                invoBil.Show();
            }
            catch (Exception) { }

            // else { toolTip_Invoice.Show("Plese Select Invoice For Print", dgv_Invoice, 1500); }
        }
Exemplo n.º 14
0
        private void warranty_newItem_Load(object sender, EventArgs e)
        {
            //-------------------------------------------Auto Invoice Number--------------------------------------------------------//
            string rNo = Invo.InvoiceNo();

            if (rNo.Equals("") || rNo == null)
            {
                iNo = 001000;
            }
            else
            {
                iNo = Convert.ToInt32(rNo);
                iNo = iNo + 1;
            }

            //---------------------------------------------Auto Itm No------------------------------------------------------------------------//

            string riNo = itemdb.Itemno();

            if (riNo.Equals("") || riNo == null)
            {
                iiNo = 001000;
            }
            else
            {
                iiNo = Convert.ToInt32(rNo);
                iiNo = iiNo + 1;
                //MessageBox.Show(iiNo.ToString());
            }



            string rcNo = itemdb.getCusno();

            if (rcNo.Equals("") || rcNo == null)
            {
                cNo = 001000;
            }
            else
            {
                cNo = Convert.ToInt32(rcNo);
                cNo = cNo + 1;
                // MessageBox.Show(cNo.ToString());
            }



            int[] numbers = new[] { iiNo, cNo };

            int max = numbers.Max();

            lbl_itNo.Text = max.ToString();



            //---------------------------------------------------------------------------------------------------------------------//

            String         sql = "SELECT*FROM tbl_brande";
            SqlDataAdapter get = new SqlDataAdapter(sql, ConnectionDB.Connection());
            DataTable      ns  = new DataTable();

            get.Fill(ns);
            for (int i = 0; i < ns.Rows.Count; i++)
            {
                cbxAddItemBrande.Items.Add(ns.Rows[i]["Brande"]);
            }


            String         csql = "SELECT*FROM tbl_catogory";
            SqlDataAdapter cget = new SqlDataAdapter(csql, ConnectionDB.Connection());
            DataTable      cdt  = new DataTable();

            cget.Fill(cdt);
            for (int i = 0; i < cdt.Rows.Count; i++)
            {
                cbxAddItemCatogory.Items.Add(cdt.Rows[i]["catogory"]);
            }


            String         tsql = "SELECT*FROM tbl_itype";
            SqlDataAdapter tget = new SqlDataAdapter(tsql, ConnectionDB.Connection());
            DataTable      tdt  = new DataTable();

            tget.Fill(tdt);
            for (int i = 0; i < tdt.Rows.Count; i++)
            {
                cbxAddItemItemType.Items.Add(tdt.Rows[i]["Item_type"]);
            }



            cbxAddItemCatogory.DropDownStyle      = System.Windows.Forms.ComboBoxStyle.DropDown;
            cbxAddItemCatogory.AutoCompleteMode   = AutoCompleteMode.SuggestAppend;
            cbxAddItemCatogory.AutoCompleteSource = AutoCompleteSource.ListItems;

            cbxAddItemBrande.DropDownStyle      = System.Windows.Forms.ComboBoxStyle.DropDown;
            cbxAddItemBrande.AutoCompleteMode   = AutoCompleteMode.SuggestAppend;
            cbxAddItemBrande.AutoCompleteSource = AutoCompleteSource.ListItems;
        }
        private void btn_chnge_Click(object sender, EventArgs e)
        {
            errorProvider2.SetError(txt_paid, "");
            errorProvider3.SetError(txt_balnce, "");
            errorProvider1.SetError(cbx_payMethord, "");

            //-------------------------------------------Auto Invoice Number--------------------------------------------------------//
            string rNo = Invo.InvoiceNo();

            if (rNo.Equals("") || rNo == null)
            {
                iNo = 001000;
            }
            else
            {
                iNo = Convert.ToInt32(rNo);
                iNo = iNo + 1;
            }
            //MessageBox.Show(iNo.ToString());

            //---------------------------------------------------------------------------------------------------------------------//
            //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++check tablen is Null++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++//
            String         emty    = "SELECT*FROM tbl_Invoice_Item";
            SqlDataAdapter iigemty = new SqlDataAdapter(emty, ConnectionDB.Connection());
            DataTable      iemty   = new DataTable();

            iigemty.Fill(iemty);
            if (0 != iemty.Rows.Count) // does not exist
            {
                //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++//


                if (cbx_payMethord.Text != "" && txt_paid.Text != "")
                {
                    if (txt_balnce.Text != "Invalaid payment..!")
                    {
                        SqlDataReader cdr = wrty.select_cusNo(Warranty_Details.dgvw.CurrentRow.Cells["Invoice_No"].Value.ToString());
                        if (cdr.Read())
                        {
                            ccno  = cdr["Coustomer_No"].ToString();
                            InvDt = Convert.ToDateTime(cdr["Invoice_Date"]);
                        }


                        //====================================================================================================================================//
                        String         iisql = "SELECT*FROM tbl_Invoice_Item";
                        SqlDataAdapter iiget = new SqlDataAdapter(iisql, ConnectionDB.Connection());
                        DataTable      iins  = new DataTable();
                        iiget.Fill(iins);
                        for (int ii = 0; ii < iins.Rows.Count; ii++)
                        {
                            inom      = iins.Rows[ii]["Item_No"].ToString();
                            inme      = iins.Rows[ii]["Item_Name"].ToString();
                            iserial   = iins.Rows[ii]["Serial_No"].ToString();
                            iselpiz   = iins.Rows[ii]["Sales_Price"].ToString();
                            ipurpiz   = iins.Rows[ii]["Purchase_Price"].ToString();
                            ictgry    = iins.Rows[ii]["Catogory"].ToString();
                            isubctgry = iins.Rows[ii]["Sub_Catogory"].ToString();
                            ibrnd     = iins.Rows[ii]["Brande"].ToString();
                            ibcode    = iins.Rows[ii]["Barcode"].ToString();
                            iwrrty    = iins.Rows[ii]["Warranty"].ToString();
                            isuppl    = iins.Rows[ii]["Supplier"].ToString();
                            itpe      = iins.Rows[ii]["Item_Type"].ToString();
                            descri    = iins.Rows[ii]["Discription"].ToString();


                            decimal pfit = (Convert.ToDecimal(iselpiz)) - (Convert.ToDecimal(ipurpiz));

                            try
                            {
                                Invo.insert_Invoice_detalis(iNo.ToString(), InvDt, inom, iserial, inme, Convert.ToDecimal(iselpiz), Convert.ToDecimal(ipurpiz), ibcode, ictgry, isubctgry, ibrnd, iwrrty, isuppl, itpe, descri, pfit, "Ok", "1");
                                // MessageBox.Show("new itttttttttmss changgggg");
                                wrty.addWary_foundItm(Warranty_Details.dgvw.CurrentRow.Cells["Warranty_No"].Value.ToString(), Warranty_Details.dgvw.CurrentRow.Cells["Invoice_No"].Value.ToString(), inom, inme, iserial, ibcode, ictgry, isubctgry, ibrnd, itpe, descri);
                                //MessageBox.Show("warranty found item");
                            }

                            catch (Exception ee)
                            {
                                MessageBox.Show(ee.Message);
                            }
                        }

                        //===================================================================================================================================//

                        //-----------------------------------------------for description-------------------------------------------------------------//

                        String         sql = "SELECT DISTINCT Catogory FROM tbl_Invoice_Item";
                        SqlDataAdapter get = new SqlDataAdapter(sql, ConnectionDB.Connection());
                        DataTable      ns  = new DataTable();
                        get.Fill(ns);
                        for (int i = 0; i < ns.Rows.Count; i++)
                        {
                            iqqqty = 0;
                            icty   = ns.Rows[i]["Catogory"].ToString();

                            String         idsql = "SELECT Quntity FROM tbl_Invoice_Item WHERE Catogory='" + icty + "'";
                            SqlDataAdapter idget = new SqlDataAdapter(idsql, ConnectionDB.Connection());
                            DataTable      idns  = new DataTable();
                            idget.Fill(idns);
                            for (int idi = 0; idi < idns.Rows.Count; idi++)
                            {
                                decimal qttt = Convert.ToDecimal(idns.Rows[idi]["Quntity"].ToString());
                                iqqqty += qttt;
                            }

                            ides += icty + iqqqty.ToString() + " ";
                        }
                        //---------------------------------------------------------------------------------------------------------------------------//


                        //===============================================================================================================================//



                        if (txt_balnce.Text == "0.00")
                        {
                            pymnt = "Ok";
                        }
                        else
                        {
                            pymnt = "Not Complete";
                        }


                        //================================================================================================================================//

                        try
                        {
                            Invo.insert_Invoice(iNo.ToString(), InvDt, Convert.ToDecimal(txt_Total.Text), (Convert.ToDecimal(txt_paid.Text)) + (Convert.ToDecimal(lbl_CurrentMoney.Text)), Convert.ToDecimal(txt_balnce.Text), cbx_payMethord.Text, ides, New_invoice.sref.Text, ccno, Convert.ToDecimal(txt_granTotal.Text), Convert.ToDecimal(txt_discount.Text), Convert.ToDecimal(txt_tax.Text), pymnt);
                            // MessageBox.Show("ADd new invo");
                            wrty.update_item_status(Warranty_Details.dgvw.CurrentRow.Cells["Invoice_No"].Value.ToString(), Warranty_Details.dgvw.CurrentRow.Cells["Item_No"].Value.ToString(), "Return");
                            // MessageBox.Show("update oled invo");
                        }
                        catch (Exception eee)
                        {
                            MessageBox.Show(eee.Message);
                        }



                        //--------------------------------------------------Remove Invoiced items From tbl_Add_Items Table---------------------------------//

                        String         dsql = "SELECT*FROM tbl_Invoice_Item";
                        SqlDataAdapter dget = new SqlDataAdapter(dsql, ConnectionDB.Connection());
                        DataTable      dns  = new DataTable();
                        dget.Fill(dns);
                        for (int di = 0; di < dns.Rows.Count; di++)
                        {
                            SqlDataReader drm = itemdb.select_to_Qntity(dns.Rows[di]["Catogory"].ToString(), dns.Rows[di]["Sub_Catogory"].ToString(), dns.Rows[di]["Brande"].ToString());
                            if (drm.Read())
                            {
                                string qqt = drm["Quntity"].ToString();
                                int    qq1 = int.Parse(qqt);
                                int    qq2 = qq1 - 1;
                                string qty = qq2.ToString();
                                itemdb.update_Quntity(qty, dns.Rows[di]["Catogory"].ToString(), dns.Rows[di]["Sub_Catogory"].ToString(), dns.Rows[di]["Brande"].ToString());
                                itemdb.delete_item(dns.Rows[di]["Item_No"].ToString());
                                // MessageBox.Show("Quntity Updated");
                            }
                        }


                        //---------------------------------------------------------------------------------------------------------------------------------//



                        //========================================Add old item to return_item table   &   qty updated================================================//



                        try
                        {
                            SqlDataReader bdr = wrty.select_invo_backI(Warranty_Details.dgvw.CurrentRow.Cells["Item_No"].Value.ToString(), Warranty_Details.dgvw.CurrentRow.Cells["Invoice_No"].Value.ToString());
                            if (bdr.Read())
                            {
                                iinme      = bdr["Item_Name"].ToString();
                                iiserial   = bdr["Serial_No"].ToString();
                                iiselpiz   = bdr["Sales_Price"].ToString();
                                iipurpiz   = bdr["Purchase_Price"].ToString();
                                iictgry    = bdr["Catogory"].ToString();
                                iisubctgry = bdr["Sub_Catogory"].ToString();
                                iibrnd     = bdr["Brande"].ToString();
                                iibcode    = bdr["Barcode"].ToString();
                                iiwrrty    = bdr["Warranty"].ToString();
                                iisuppl    = bdr["Supplier"].ToString();
                                iitpe      = bdr["Item_Type"].ToString();
                                iidescri   = bdr["Discription"].ToString();

                                //////

                                wrty.insert_retn_itm(Warranty_Details.dgvw.CurrentRow.Cells["Item_No"].Value.ToString(), iiserial, iinme, Convert.ToDecimal(iiselpiz), Convert.ToDecimal(iipurpiz), Convert.ToDecimal("0"), iibcode, iictgry, iisubctgry, iibrnd, iitpe, iisuppl, iiwrrty, iidescri);
                                // MessageBox.Show("add to return item");
                            }
                        }
                        catch (Exception ee)
                        {
                            MessageBox.Show(ee.Message);
                        }


                        //=========================================================================================================================================//
                        wty_dtail_inconplete.newItm = true;
                        if (MessageBox.Show("Retun By Stock Item", "Sharp Creation", MessageBoxButtons.OK, MessageBoxIcon.Information) == DialogResult.OK)

                        {
                            if (cb_printi.Checked == true)
                            {
                                //==========================================================================================================================

                                SqlDataReader ziddr = Invo.select_invoNo(iNo.ToString());
                                if (ziddr.Read())
                                {
                                    invodate = Convert.ToDateTime(ziddr["Invoice_Date"].ToString());
                                    total    = ziddr["Total_Price"].ToString();
                                    paid     = ziddr["Paid_Price"].ToString();
                                    blnc     = ziddr["Balance"].ToString();
                                    cusnom   = ziddr["Coustomer_No"].ToString();
                                    paymethd = ziddr["Payment_Method"].ToString();
                                    grantota = ziddr["Grande_total"].ToString();
                                    disc     = ziddr["Discount"].ToString();
                                    tax      = ziddr["Tax"].ToString();
                                }

                                SqlDataReader zdrcus = Invo.select_incus(cusnom);
                                if (zdrcus.Read())
                                {
                                    fname = zdrcus["First_Name"].ToString();
                                    lnme  = zdrcus["Last_Name"].ToString();
                                    add1  = zdrcus["Address_Line1"].ToString();
                                    add2  = zdrcus["Address_Line2"].ToString();
                                    mobl  = zdrcus["Mobile"].ToString();
                                }
                                else
                                {
                                    fname = "N/A";
                                    lnme  = "N/A";
                                    add1  = "N/A";
                                    add2  = "N/A";
                                    mobl  = "N/A";
                                }



                                String         ibsql = "SELECT*FROM tbl_Invoice_details WHERE Invoice_No='" + iNo + "'";
                                SqlDataAdapter ibget = new SqlDataAdapter(ibsql, ConnectionDB.Connection());
                                DataTable      ibns  = new DataTable();
                                ibget.Fill(ibns);
                                for (int ib = 0; ib < ibns.Rows.Count; ib++)
                                {
                                    itmno      = ibns.Rows[ib]["Item_No"].ToString();
                                    itmNme     = ibns.Rows[ib]["Item_Name"].ToString();
                                    itmseril   = ibns.Rows[ib]["Serial_No"].ToString();
                                    itsalepriz = ibns.Rows[ib]["Sales_Price"].ToString();
                                    itmctgy    = ibns.Rows[ib]["Catogory"].ToString();
                                    itmsbctgy  = ibns.Rows[ib]["Sub_Catogory"].ToString();
                                    itmbrnd    = ibns.Rows[ib]["Brande"].ToString();
                                    itmwarrty  = ibns.Rows[ib]["Warranty"].ToString();


                                    iqty = ibns.Rows[ib]["Quntity"].ToString();



                                    //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ check- is bill table Null...? ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++//
                                    String         emty_ibl    = "SELECT*FROM tbl_Invoice_bill";
                                    SqlDataAdapter iigemty_bil = new SqlDataAdapter(emty_ibl, ConnectionDB.Connection());
                                    DataTable      iemty_bil   = new DataTable();
                                    iigemty_bil.Fill(iemty_bil);
                                    if (0 != iemty_bil.Rows.Count) // does not exist
                                    {
                                        //___________________________________________________________________________________________________________________________
                                        SqlDataReader slct_billDR = Invo.select_invtmp_bil(itmctgy, itmsbctgy, itmbrnd);
                                        if (slct_billDR.Read())
                                        {
                                            string bsril, bqtyy, u_piz; decimal n_qty;

                                            bsril = slct_billDR["Serial_No"].ToString();
                                            bqtyy = slct_billDR["Quantity"].ToString();
                                            u_piz = slct_billDR["Unit_Price"].ToString();
                                            n_qty = Convert.ToDecimal(bqtyy) + Convert.ToDecimal(iqty);

                                            Invo.Updte_invc_bill(itmctgy, itmsbctgy, itmbrnd, n_qty, (Convert.ToDecimal(u_piz) * n_qty), bsril + "," + itmseril);
                                            //MessageBox.Show("update_Dtail");
                                        }
                                        else
                                        {
                                            try
                                            {
                                                Invo.insert_Invoice_Bill(iNo.ToString(), invodate, fname + " " + lnme, add1 + " " + add2, mobl, Convert.ToDecimal(grantota), Convert.ToDecimal(disc), Convert.ToDecimal(tax), Convert.ToDecimal(total), Convert.ToDecimal(paid), paymethd, Convert.ToDecimal(blnc), itmseril, itmctgy, itmsbctgy, itmbrnd, itmbrnd + " " + itmNme + " " + itmctgy + " " + itmsbctgy + " \nWarranty- " + itmwarrty, Convert.ToDecimal(Convert.ToDecimal(itsalepriz) / Convert.ToDecimal(iqty)), Convert.ToDecimal(iqty), Convert.ToDecimal(itsalepriz));

                                                //MessageBox.Show("Invoice bill add");
                                            }
                                            catch (Exception ex)
                                            { MessageBox.Show(ex.Message); }
                                        }

                                        //___________________________________________________________________________________________________________________________
                                    }
                                    else
                                    {
                                        try
                                        {
                                            Invo.insert_Invoice_Bill(iNo.ToString(), invodate, fname + " " + lnme, add1 + " " + add2, mobl, Convert.ToDecimal(grantota), Convert.ToDecimal(disc), Convert.ToDecimal(tax), Convert.ToDecimal(total), Convert.ToDecimal(paid), paymethd, Convert.ToDecimal(blnc), itmseril, itmctgy, itmsbctgy, itmbrnd, itmbrnd + " " + itmNme + " " + itmctgy + " " + itmsbctgy + " \nWarranty- " + itmwarrty, Convert.ToDecimal(Convert.ToDecimal(itsalepriz) / Convert.ToDecimal(iqty)), Convert.ToDecimal(iqty), Convert.ToDecimal(itsalepriz));

                                            //MessageBox.Show("Invoice bill add");
                                        }
                                        catch (Exception ex)
                                        { MessageBox.Show(ex.Message); }
                                    }
                                }

                                Bill invoBil = new Bill();
                                invoBil.ShowDialog();



                                //============================================================================================================================



                                //============================================================================================================================
                            }



                            btn_warrtySave = true;
                            wty_dtail_inconplete.bt_save = true;
                            this.Close();
                        }

                        //=========================================================================================================================================//
                    }

                    else
                    {
                        errorProvider2.SetError(txt_paid, "Invalid payment");
                        errorProvider3.SetError(txt_balnce, "Invalid payment");
                    }
                }

                else
                {
                    if (cbx_payMethord.Text == "")
                    {
                        errorProvider1.SetError(cbx_payMethord, "Complete warranty");
                    }
                    if (txt_paid.Text == "")
                    {
                        toolTipselect.Show("No Payment Enter", txt_paid, 1000);
                    }
                }
            }
            else
            {
                toolTipselect.Show("Select items to Change", button_SearchItem, 0, 75, 2500);
            }
        }
        private void Edit_Receive_Stock_Load(object sender, EventArgs e)
        {
            //--------------------------------Supplier_Account Close-----------------------------------//
            for (int index = Application.OpenForms.Count - 1; index >= 0; index--)
            {
                if (Application.OpenForms[1].Name == "Supplier_Account")

                {
                    Application.OpenForms[1].Close();
                }
            }
            //---------------------------------------------------------------------------------//



            lbl_s_no.Text         = supA.stNo;
            dtp_AccUp.Text        = supA.stDate;
            txtDiscription.Text   = supA.st_descrip;
            txtPurchasePrice.Text = supA.purchPriz;
            lbl_totPaid.Text      = supA.paid;
            txt_paid.Text         = supA.paid;
            cbx_supp.Text         = supA.stSup;
            cbx_pymetd.Text       = supA.payMethd;
            txt_inme.Text         = supA.nme;
            cbx_qty_ctgy.Text     = supA.catgy;
            cbx_qty_S_ctgy.Text   = supA.subcgy;
            cbx_qty_Brand.Text    = supA.brand;
            cbx_itmtype.Text      = supA.itype;
            txt_u_p_priz.Text     = supA.un_piz;
            txt_u_s_priz.Text     = supA.un_sal;
            numericUpDown1.Value  = Convert.ToDecimal(supA.qqty);



            String         sql = "SELECT*FROM tbl_AddS_Supplier";
            SqlDataAdapter get = new SqlDataAdapter(sql, ConnectionDB.Connection());
            DataTable      ns  = new DataTable();

            get.Fill(ns);
            for (int i = 0; i < ns.Rows.Count; i++)
            {
                cbx_supp.Items.Add(ns.Rows[i]["Business_Name"]);
            }

//////////////////////////////////////////////////////////////////////////////////////
            SqlDataReader dr = supOp.selectB(lbl_s_no.Text);

            if (dr.Read())
            {
                string  tot, paid, balnce;
                decimal tot1, paid1, balnce1;
                tot     = dr["Purchase_Price"].ToString();
                paid    = dr["Payment"].ToString();
                tot1    = decimal.Parse(tot);
                paid1   = decimal.Parse(paid);
                balnce1 = (tot1 - paid1);
                balnce  = balnce1.ToString();

                lbl_old_blnc.Text = balnce;
                lbl_Balance.Text  = "Rs : " + balnce;
                lblNew_paid.Text  = "Rs : " + paid;
                if (balnce1 == 0)
                {
                    groupBox_pay.Enabled  = false;
                    lbl_completed.Visible = true;
                }
            }



            String         csql = "SELECT*FROM tbl_catogory";
            SqlDataAdapter cget = new SqlDataAdapter(csql, ConnectionDB.Connection());
            DataTable      cdt  = new DataTable();

            cget.Fill(cdt);
            for (int i = 0; i < cdt.Rows.Count; i++)
            {
                cbx_qty_ctgy.Items.Add(cdt.Rows[i]["catogory"]);
            }


            //String scsql = "SELECT*FROM tbl_sub_catogory";
            //SqlDataAdapter scget = new SqlDataAdapter(scsql, ConnectionDB.Connection());
            //DataTable scdt = new DataTable();
            //scget.Fill(scdt);
            //for (int i = 0; i < scdt.Rows.Count; i++)
            //{
            //    cbxAddItemSubCatogory.Items.Add(scdt.Rows[i]["sub_catogory"]);
            //}


            String         bsql = "SELECT*FROM tbl_brande";
            SqlDataAdapter bget = new SqlDataAdapter(bsql, ConnectionDB.Connection());
            DataTable      bdt  = new DataTable();

            bget.Fill(bdt);
            for (int i = 0; i < bdt.Rows.Count; i++)
            {
                cbx_qty_Brand.Items.Add(bdt.Rows[i]["Brande"]);
            }



            String         tsql = "SELECT*FROM tbl_itype";
            SqlDataAdapter tget = new SqlDataAdapter(tsql, ConnectionDB.Connection());
            DataTable      tdt  = new DataTable();

            tget.Fill(tdt);
            for (int i = 0; i < tdt.Rows.Count; i++)
            {
                cbx_itmtype.Items.Add(tdt.Rows[i]["Item_type"]);
            }
        }
Exemplo n.º 17
0
        private void btnAddItemAddItem_Click(object sender, EventArgs e)
        {
            ep_iname.SetError(txtAddItemItemName, "");
            ep_isalePrz.SetError(txtAddItemSalesPrice, "");
            ep_ipuchsPriz.SetError(txtAddItemPurchasePrice, "");
            ep_isupp.SetError(cbxAddItemSupplier, "");
            ep_ictogry.SetError(cbxAddItemCatogory, "");
            ep_isubCotory.SetError(cbxAddItemSubCatogory, "");
            ep_ibrnd.SetError(cbxAddItemBrande, "");



            string warrty;

            if (cb_warnty.Checked == true)
            {
                string wtyNo = cbx_wrty_number.Text;
                string wtydu = cbx_wrty_duretion.Text;
                warrty = wtyNo + " " + wtydu;
            }
            else
            {
                warrty = "No Warranty";
            }
            try
            {
                if (txtAddItemBarcode.Text != "" || txtAddItemSerial.Text != "")
                {
                    if (txtAddItemItemName.Text != "" && txtAddItemSalesPrice.Text != "" && txtAddItemPurchasePrice.Text != "" && cbxAddItemCatogory.Text != "" && cbxAddItemSubCatogory.Text != "" && cbxAddItemBrande.Text != "" && cbxAddItemSupplier.Text != "")
                    {
                        if (cb_warnty.Checked == true)
                        {
                            if (cbx_wrty_number.Text != "" && cbx_wrty_duretion.Text != "")
                            {
                                string     sql = "UPDATE tbl_Add_Items SET Serial_No='" + txtAddItemSerial.Text + "',Item_Name='" + txtAddItemItemName.Text + "',Sales_Price='" + Convert.ToDecimal(txtAddItemSalesPrice.Text) + "',Purchase_Price='" + Convert.ToDecimal(txtAddItemPurchasePrice.Text) + "',Tax_Rate='" + Convert.ToDecimal(txtAddItemTaxRate.Text) + "',Barcode='" + txtAddItemBarcode.Text + "',Catogory='" + cbxAddItemCatogory.Text + "',Sub_Catogory='" + cbxAddItemSubCatogory.Text + "',Brande='" + cbxAddItemBrande.Text + "',Item_Type='" + cbxAddItemItemType.Text + "',Supplier='" + cbxAddItemSupplier.Text + "',Warranty='" + warrty + "',Discription='" + txtAddItemDiscription.Text + "' WHERE Item_No='" + lbl_itemNo.Text + "'";
                                SqlCommand com = new SqlCommand(sql, ConnectionDB.Connection());
                                com.ExecuteNonQuery();

                                // MessageBox.Show("Item Added");

                                //SqlDataReader dr = itemdb.select_to_Qntity(cbxAddItemCatogory.Text, cbxAddItemSubCatogory.Text, cbxAddItemBrande.Text);
                                //if (dr.Read())
                                //{
                                //    string qt = dr["Quntity"].ToString();
                                //    int q1 = int.Parse(qt);
                                //    int q2 = q1 + 1;
                                //    string qty = q2.ToString();
                                //    itemdb.update_Quntity(qty, cbxAddItemCatogory.Text, cbxAddItemSubCatogory.Text, cbxAddItemBrande.Text);
                                //    //  MessageBox.Show("Quntity Updated");

                                //}
                                //else
                                //{
                                //    itemdb.Quntity(txtAddItemItemName.Text,cbxAddItemCatogory.Text, cbxAddItemSubCatogory.Text, cbxAddItemBrande.Text, "1",txtAddItemPurchasePrice.Text,txtAddItemSalesPrice.Text);
                                //    // MessageBox.Show("quntity Added");
                                //}


                                //SqlDataReader drm = itemdb.select_to_Qntity(itup.catogy, itup.subCatogy, itup.Brande);
                                //if (drm.Read())
                                //{
                                //    string qqt = drm["Quntity"].ToString();
                                //    int qq1 = int.Parse(qqt);
                                //    int qq2 = qq1 - 1;
                                //    string qty = qq2.ToString();
                                //    itemdb.update_Quntity(qty, itup.catogy, itup.subCatogy, itup.Brande);
                                //    //  MessageBox.Show("Quntity Updated");

                                //}



                                if (MessageBox.Show("Item Updated Successfuly.", "Update Item", MessageBoxButtons.OK, MessageBoxIcon.Information) == DialogResult.OK)
                                {
                                    this.Close();
                                    Main.p1.Controls.Clear();
                                    Find_item d1 = new Find_item();
                                    d1.TopLevel = false;
                                    d1.Visible  = true;
                                    Main.p1.Controls.Add(d1);
                                }
                            }

                            else
                            {
                                ep_warrnty.SetError(cbx_wrty_duretion, "Complete warranty");
                            }
                        }


                        else
                        {
                            string     sql = "UPDATE tbl_Add_Items SET Serial_No='" + txtAddItemSerial.Text + "',Item_Name='" + txtAddItemItemName.Text + "',Sales_Price='" + txtAddItemSalesPrice.Text + "',Purchase_Price='" + txtAddItemPurchasePrice.Text + "',Tax_Rate='" + txtAddItemTaxRate.Text + "',Barcode='" + txtAddItemBarcode.Text + "',Catogory='" + cbxAddItemCatogory.Text + "',Sub_Catogory='" + cbxAddItemSubCatogory.Text + "',Brande='" + cbxAddItemBrande.Text + "',Item_Type='" + cbxAddItemItemType.Text + "',Supplier='" + cbxAddItemSupplier.Text + "',Warranty='" + warrty + "',Discription='" + txtAddItemDiscription.Text + "' WHERE Item_No='" + lbl_itemNo.Text + "'";
                            SqlCommand com = new SqlCommand(sql, ConnectionDB.Connection());
                            com.ExecuteNonQuery();

                            // MessageBox.Show("Item Added");

                            SqlDataReader dr = itemdb.select_to_Qntity(cbxAddItemCatogory.Text, cbxAddItemSubCatogory.Text, cbxAddItemBrande.Text);
                            if (dr.Read())
                            {
                                string qt  = dr["Quntity"].ToString();
                                int    q1  = int.Parse(qt);
                                int    q2  = q1 + 1;
                                string qty = q2.ToString();
                                itemdb.update_Quntity(qty, cbxAddItemCatogory.Text, cbxAddItemSubCatogory.Text, cbxAddItemBrande.Text);
                                //  MessageBox.Show("Quntity Updated");
                            }
                            else
                            {
                                itemdb.Quntity(txtAddItemItemName.Text, cbxAddItemCatogory.Text, cbxAddItemSubCatogory.Text, cbxAddItemBrande.Text, "1", txtAddItemPurchasePrice.Text, txtAddItemSalesPrice.Text);
                                // MessageBox.Show("quntity Added");
                            }


                            SqlDataReader drm = itemdb.select_to_Qntity(itup.catogy, itup.subCatogy, itup.Brande);
                            if (drm.Read())
                            {
                                string qqt = drm["Quntity"].ToString();
                                int    qq1 = int.Parse(qqt);
                                int    qq2 = qq1 - 1;
                                string qty = qq2.ToString();
                                itemdb.update_Quntity(qty, itup.catogy, itup.subCatogy, itup.Brande);
                                //  MessageBox.Show("Quntity Updated");
                            }



                            if (MessageBox.Show("Item Updated Successfuly.", "Update Item", MessageBoxButtons.OK, MessageBoxIcon.Information) == DialogResult.OK)
                            {
                                this.Close();
                                Main.p1.Controls.Clear();
                                Find_item d1 = new Find_item();
                                d1.TopLevel = false;
                                d1.Visible  = true;
                                Main.p1.Controls.Add(d1);
                            }
                        }
                    }
                    else
                    {
                        if (txtAddItemItemName.Text == "")
                        {
                            ep_iname.SetError(txtAddItemItemName, "Enter Item name");
                        }

                        if (txtAddItemSalesPrice.Text == "")
                        {
                            ep_isalePrz.SetError(txtAddItemSalesPrice, "Enter Item Sales Price");
                        }

                        if (txtAddItemPurchasePrice.Text == "")
                        {
                            ep_ipuchsPriz.SetError(txtAddItemPurchasePrice, "Enter Item Purchas Price");
                        }

                        if (cbxAddItemSupplier.Text == "")
                        {
                            ep_isupp.SetError(cbxAddItemSupplier, "Choose Supplier name");
                        }

                        if (cbxAddItemCatogory.Text == "")
                        {
                            ep_ictogry.SetError(cbxAddItemCatogory, "Choose Item Catogary");
                        }

                        if (cbxAddItemSubCatogory.Text == "")
                        {
                            ep_isubCotory.SetError(cbxAddItemSubCatogory, "Choose Item sub Catogary");
                        }

                        if (cbxAddItemBrande.Text == "")
                        {
                            ep_ibrnd.SetError(cbxAddItemBrande, "Choose Item Brande");
                        }


                        tp_required.Show("Fill Require fileds", btnAddItemAddItem, 5000);
                    }
                }
                else
                {
                    tp_seril_barcobe.Show("Must Enter Serial or Barcode For Iditify Items", lbl_tp, 4000);
                }
            }



            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }