Пример #1
0
        private void fillAllPayables()
        {
            try
            {
                Varibles.setConnection();
                cmd = Varibles.getCommand();

                DateTime date1 = new DateTime(dtp_from.Value.Year, dtp_from.Value.Month, dtp_from.Value.Day, 0, 0, 0);

                DateTime date2 = new DateTime(dtp_to.Value.Year, dtp_to.Value.Month, dtp_to.Value.Day, 23, 59, 59);


                String query = "SELECT CLT_NAME , TE_BLNCE, TE_IN, TE_OUT, TE_CMMTS, TE_DATE FROM merp.treasuryentries , merp.clients " +
                               " WHERE TE_CLNT_ID = CLT_ID AND TE_CLNT_ID is not NULL AND TE_DATE <= '" + date2.ToString("yyyy-MM-dd HH:mm:ss") +
                               "' AND TE_DATE >= '" + date1.ToString("yyyy-MM-dd HH:mm:ss") + "' ;";


                cmd.CommandText = query;
                reader          = cmd.ExecuteReader();

                Double   PaidHim, PaidME, Balance;
                DateTime InvDate;
                String   Comments, clientName;

                while (reader.Read())
                {
                    clientName = reader.GetString("CLT_NAME");
                    PaidME     = reader.GetDouble("TE_IN");;
                    PaidHim    = reader.GetDouble("TE_OUT");
                    Balance    = reader.GetDouble("TE_BLNCE");
                    InvDate    = reader.GetDateTime("TE_DATE");
                    Comments   = reader.GetString("TE_CMMTS");

                    dGridV_InvenLog.Rows.Add(Balance, clientName, PaidME, PaidHim, "اذن دفع", InvDate, Comments);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            finally
            {
                reader.Close();
                Varibles.closeConnection();
            }
        }
Пример #2
0
        public ProductAdditionForm()
        {
            InitializeComponent();
            this.BackgroundImageLayout = ImageLayout.Stretch;
            this.Icon        = Properties.Resources.merp1_ExR_icon;
            this.MaximizeBox = false;
            Varibles.setConnection();
            cmd = Varibles.getCommand();

            fillProdTypes();

            cmbbx_NewProdType.SelectedIndex = -1;

            showAll(false);

            loadCode();
        }
Пример #3
0
 private void IncSupplier(int SuppID, Double amount)
 {
     try
     {
         Varibles.setConnection();
         cmd = Varibles.getCommand();
         String query = "UPDATE `merp`.`suppliers` SET `SPLR_BLNCE`= SPLR_BLNCE + " + amount + " WHERE `SPLR_ID`='" + SuppID + "'";
         cmd.CommandText = query;
         cmd.ExecuteNonQuery();
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }finally{
         Varibles.closeConnection();
     }
 }
Пример #4
0
        private void fillAllInvoices()
        {
            try
            {
                Varibles.setConnection();
                cmd = Varibles.getCommand();

                DateTime date1 = new DateTime(dtp_from.Value.Year, dtp_from.Value.Month, dtp_from.Value.Day, 0, 0, 0);

                DateTime date2 = new DateTime(dtp_to.Value.Year, dtp_to.Value.Month, dtp_to.Value.Day, 23, 59, 59);

                String query = "SELECT CLT_NAME , INV_CRNTBLNCE, INV_TOTAL, INV_DATE FROM merp.invoices , merp.clients WHERE" +
                               " CLT_ID = INV_CLNT AND INV_DATE <= '" + date2.ToString("yyyy-MM-dd HH:mm:ss") + "' AND INV_DATE >= '" + date1.ToString("yyyy-MM-dd HH:mm:ss") + "' AND INV_CLNT is not NULL ;";



                cmd.CommandText = query;
                reader          = cmd.ExecuteReader();

                Double   For, Against, Balance;
                DateTime InvDate;
                String   clientName;

                while (reader.Read())
                {
                    clientName = reader.GetString("CLT_NAME");
                    Against    = reader.GetDouble("INV_TOTAL");
                    For        = 0;
                    Balance    = reader.GetDouble("INV_CRNTBLNCE");
                    InvDate    = reader.GetDateTime("INV_DATE");

                    dGridV_InvenLog.Rows.Add(Balance, clientName, For, Against, "فاتوره", InvDate, "");
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            finally
            {
                reader.Close();
                Varibles.closeConnection();
            }
        }
Пример #5
0
 private void updatePaper(int paperID, int newState)
 {
     try
     {
         Varibles.setConnection();
         cmd = Varibles.getCommand();
         String query = "UPDATE `merp`.`payment_papers` SET `PYMNT_STATE`='" + newState + "' WHERE `PYMNTP_ID`='" + paperID + "'";
         cmd.CommandText = query;
         cmd.ExecuteNonQuery();
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
     finally
     {
         Varibles.closeConnection();
     }
 }
Пример #6
0
 private void IncClientBalance(int ClientID, Double Amount)
 {
     try
     {
         Varibles.setConnection();
         cmd = Varibles.getCommand();
         String query = "UPDATE `merp`.`clients` SET `CLNT_BLNCE`= CLNT_BLNCE + " + Amount + " WHERE `CLT_ID`='" + ClientID + "'";
         cmd.CommandText = query;
         cmd.ExecuteNonQuery();
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
     finally
     {
         Varibles.closeConnection();
     }
 }
Пример #7
0
 private void UpdateRecPapers(int pprID, int newState)
 {
     try
     {
         Varibles.setConnection();
         cmd = Varibles.getCommand();
         String query = "UPDATE `merp`.`receivable_papers` SET `RCVP_STATE`='" + newState + "' WHERE `RCVP_ID`='" + pprID + "'";
         cmd.CommandText = query;
         cmd.ExecuteNonQuery();
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
     finally
     {
         Varibles.closeConnection();
     }
 }
Пример #8
0
        public ProdTypeMod()
        {
            InitializeComponent();
            this.BackgroundImageLayout = ImageLayout.Stretch;
            this.Icon = Properties.Resources.merp1_ExR_icon;
            Varibles.setConnection();
            cmd = Varibles.getCommand();

            fillProdTypes();

            cmbbx_ProdType.SelectedIndex = -1;

            txtbx_editProdName.Enabled = false;
            btn_Edit.Enabled           = false;
            btn_Add.Enabled            = false;


            this.ActiveControl = txtbx_NewProdType;
        }
Пример #9
0
        private void loadClientBalance()
        {
            try
            {
                Varibles.setConnection();
                cmd = Varibles.getCommand();

                int cltNameID = Convert.ToInt32(clientNameComboBox.SelectedValue);

                String query = "SELECT CLNT_BLNCE FROM merp.clients WHERE CLT_ID = '" + cltNameID + "' ;";

                cmd.CommandText = query;

                reader = cmd.ExecuteReader();

                cltBalance = 0;
                while (reader.Read())
                {
                    try
                    {
                        cltBalance = reader.GetDouble("CLNT_BLNCE");
                    }
                    catch (Exception ex)
                    {
                        cltBalance = 0;
                    }
                }


                double tempCltBalance = cltBalance * (-1);
                clientBalanceTextBox.Text = tempCltBalance.ToString("0.00");
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            finally
            {
                reader.Close();
                Varibles.closeConnection();
            }
        }
Пример #10
0
        private int getItemBalance(int id)
        {
            try
            {
                Varibles.setConnection();
                cmd = Varibles.getCommand();

                int prdID = id;

                String query = "SELECT PRD_BALANCE FROM merp.products WHERE PRD_ID = " + prdID + " ;";

                cmd.CommandText = query;

                reader = cmd.ExecuteReader();

                int itemBlnc = 0;
                while (reader.Read())
                {
                    try
                    {
                        itemBlnc = reader.GetInt32("PRD_BALANCE");
                    }
                    catch (Exception ex)
                    {
                        itemBlnc = 0;
                    }
                }

                return(itemBlnc);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
                return(0);
            }
            finally
            {
                reader.Close();
                Varibles.closeConnection();
            }
        }
Пример #11
0
        private void changeBtn_Click(object sender, EventArgs e)
        {
            if (newUser.Text == "")
            {
                newUser.Focus(); MessageBox.Show("من فضلك إستكمل البيانات المطلوبة"); return;
            }
            ;
            if (newPass.Text == "")
            {
                newPass.Focus(); MessageBox.Show("من فضلك إستكمل البيانات المطلوبة"); return;
            }
            ;

            try
            {
                Varibles.setConnection();
                cmd = Varibles.getCommand();

                String username = newUser.Text;
                String pass     = newPass.Text;

                String condition = " USR_ID = " + "1";
                cmd.CommandText = "UPDATE        merp.users" +
                                  " SET  USR_NAME = '" + username + "' , USR_PASS = '******'" +
                                  " WHERE        ( " + condition + " )";



                cmd.ExecuteReader().Close();
                Varibles.closeConnection();

                MessageBox.Show("تم تعديل بيانات المدير بنجاح");


                this.Close();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Пример #12
0
        private void UpdateSuppBalance()
        {
            try
            {
                double suppBalance = getSuppBalance(suppID);
                Varibles.setConnection();
                cmd = Varibles.getCommand();

                string query = "UPDATE `merp`.`suppliers` SET `SPLR_BLNCE`='" + (suppBalance - paymentAmount) + "' WHERE `SPLR_ID`='" + suppID + "'";
                cmd.CommandText = query;
                cmd.ExecuteNonQuery();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            finally
            {
                Varibles.closeConnection();
            }
        }
Пример #13
0
        private void UpdateClientBalance()
        {
            try
            {
                double clientBalance = getClientBalance(clientID);

                Varibles.setConnection();
                cmd = Varibles.getCommand();
                string query = "UPDATE `merp`.`clients` SET `CLNT_BLNCE`='" + (clientBalance + paymentAmount) + "' WHERE `CLT_ID` = '" + clientID + "'";
                cmd.CommandText = query;
                cmd.ExecuteNonQuery();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            finally
            {
                Varibles.closeConnection();
            }
        }
Пример #14
0
        private void loadAllClientsBalance()
        {
            try
            {
                Varibles.setConnection();
                cmd = Varibles.getCommand();

                String query = "SELECT SUM(CLNT_BLNCE) AS SUMCLNT_BLNCE FROM merp.clients ;";

                cmd.CommandText = query;

                reader = cmd.ExecuteReader();

                cltBalance = 0;
                while (reader.Read())
                {
                    try
                    {
                        cltBalance = reader.GetDouble("SUMCLNT_BLNCE");
                    }
                    catch (Exception ex)
                    {
                        cltBalance = 0;
                    }
                }


                double tempCltBalance = cltBalance * (-1);
                clientBalanceTextBox.Text = tempCltBalance.ToString("0.00");
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            finally
            {
                reader.Close();
                Varibles.closeConnection();
            }
        }
Пример #15
0
        private double getClientBalance(int clientID)
        {
            try
            {
                Varibles.setConnection();
                cmd = Varibles.getCommand();


                String query = "SELECT CLNT_BLNCE FROM merp.clients WHERE CLT_ID = '" + clientID + "' ;";

                cmd.CommandText = query;

                reader = cmd.ExecuteReader();

                double cltBalance = 0;
                while (reader.Read())
                {
                    try
                    {
                        cltBalance = reader.GetDouble("CLNT_BLNCE");
                    }
                    catch (Exception ex)
                    {
                        cltBalance = 0;
                    }
                }

                return(cltBalance);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            finally
            {
                reader.Close();
                Varibles.closeConnection();
            }
            return(0);
        }
Пример #16
0
        private double getSuppBalance(int suppID)
        {
            try
            {
                Varibles.setConnection();
                cmd = Varibles.getCommand();


                String query = "SELECT SPLR_BLNCE FROM merp.suppliers WHERE SPLR_ID = '" + suppID + "' ;";

                cmd.CommandText = query;

                reader = cmd.ExecuteReader();

                double splrBalance = 0;
                while (reader.Read())
                {
                    try
                    {
                        splrBalance = reader.GetDouble("SPLR_BLNCE");
                    }
                    catch (Exception ex)
                    {
                        splrBalance = 0;
                    }
                }

                return(splrBalance);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            finally
            {
                reader.Close();
                Varibles.closeConnection();
            }
            return(0);
        }
Пример #17
0
        public ItemCatalogeEdit()
        {
            InitializeComponent();
            this.BackgroundImageLayout = ImageLayout.Stretch;
            this.Icon        = Properties.Resources.merp1_ExR_icon;
            this.MaximizeBox = false;
            Varibles.setConnection();
            cmd = Varibles.getCommand();

            fillProdTypes(); //Fill Prod Types Combobox
            cmbbx_ProdType.SelectedIndex = -1;


            fillProdTypes2();

            cmbbx_NewProdType.SelectedIndex = -1;


            btn_ChooseProd.Enabled = false;

            this.groupBox2.Enabled = false;
        }
Пример #18
0
        private bool isInStock(int prdId, double prdBuyPrice)
        {
            Varibles.setConnection();
            cmd = Varibles.getCommand();
            int count = 0;

            try
            {
                String query = "SELECT COUNT(*) AS count FROM stock where stock.prod_id = '" + prdId + "' AND stock.buy_price = '" + prdBuyPrice + "'";

                cmd.CommandText = query;

                reader = cmd.ExecuteReader();

                while (reader.Read())
                {
                    count = reader.GetInt32("count");
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            finally
            {
                reader.Close();
                Varibles.closeConnection();
            }


            if (count == 0)
            {
                return(false);
            }
            else
            {
                return(true);
            }
        }
Пример #19
0
        private void fillprodNames()
        {
            try
            {
                Varibles.setConnection();
                cmd = Varibles.getCommand();

                int prodTypeID = Convert.ToInt32(this.cmbbx_ProdType.SelectedValue);

                String sqlCommand = "SELECT PRD_ID, PRD_NAME, PRDTYP_NAME,  PRD_BALANCE, PRD_WHLSALEPRICE, PRD_SCTRPRICE, PRD_BUYPRICE " +
                                    " FROM merp.products , merp.prod_types WHERE PRDTYP_ID = PRD_TYPE_ID AND PRD_TYPE_ID = " + prodTypeID;

                cmd.CommandText = sqlCommand;

                MySqlDataAdapter da = new MySqlDataAdapter(sqlCommand, Varibles.getConnection());
                DataSet          ds = new DataSet();
                da.Fill(ds);
                cmd.ExecuteNonQuery();

                cmbbx_ProdName.DisplayMember = "PRD_NAME";
                cmbbx_ProdName.ValueMember   = "PRD_ID";
                cmbbx_ProdName.DataSource    = ds.Tables[0];


                cmbbx_ProdName.AutoCompleteMode   = AutoCompleteMode.Suggest;
                cmbbx_ProdName.AutoCompleteSource = AutoCompleteSource.ListItems;

                cmbbx_ProdName.SelectedIndex = -1;
                txt_Count.Text = "0";
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            finally
            {
                Varibles.closeConnection();
            }
        }
Пример #20
0
        private bool checkStock(int pr_id, int pr_balance, String pr_name)
        {
            try //check stock
            {
                Varibles.setConnection();
                cmd = Varibles.getCommand();

                int stock_balance = 0;



                if (isInStock(pr_id))
                {
                    stock_balance = balanceInStock(pr_id);

                    if (pr_balance > stock_balance)
                    {
                        MessageBox.Show("خطأ" + " " + "العدد الموجود من هذا الصنف" + "\n" + pr_name + "\n" + "في المخزن" + " " + stock_balance);
                        return(false);
                    }
                }
                else
                {
                    MessageBox.Show("خطأ" + " " + "لا يوجد من هذا الصنف" + "\n" + pr_name + "\n" + "في المخزن");
                    return(false);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
                return(false);
            }
            finally
            {
                Varibles.closeConnection();
            }

            return(true);
        }
Пример #21
0
        public void showInfo()
        {
            try
            {
                if (!lock1)
                {
                    Varibles.setConnection();
                    cmd = Varibles.getCommand();

                    String sqlCommand = "Select SPLR_RespName , SPLR_EMAIL , SPLR_TEL , SPLR_MOB , SPLR_ADRS FROM merp.suppliers WHERE SPLR_NAME LIKE '" + supplierNameComboBox.Text + "'";
                    cmd.CommandText = sqlCommand;

                    reader = cmd.ExecuteReader();

                    if (reader.HasRows)
                    {
                        while (reader.Read())
                        {
                            formFormat(false);
                            supplierRespTB.Text = reader.GetString(0);
                            emailTB.Text        = reader.GetString(1);
                            PhoneTB.Text        = reader.GetString(2);
                            mobileTB.Text       = reader.GetString(3);
                            addressTB.Text      = reader.GetString(4);
                        }
                    }
                    else
                    {
                        formFormat(true);
                    }
                    reader.Close();
                    Varibles.closeConnection();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Пример #22
0
        private void loadSupplierBalance()
        {
            try
            {
                Varibles.setConnection();
                cmd = Varibles.getCommand();

                int splrNameID = Convert.ToInt32(supplierNameComboBox.SelectedValue);

                String query = "SELECT SPLR_BLNCE FROM merp.suppliers WHERE SPLR_ID = '" + splrNameID + "' ;";

                cmd.CommandText = query;

                reader = cmd.ExecuteReader();

                while (reader.Read())
                {
                    try
                    {
                        splrBalance = reader.GetDouble("SPLR_BLNCE");
                    }
                    catch (Exception ex)
                    {
                        splrBalance = 0;
                    }
                }

                supplierBalanceTextBox.Text = splrBalance.ToString("0.00");
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            finally
            {
                reader.Close();
                Varibles.closeConnection();
            }
        }
Пример #23
0
        private void loadAllSupplierBalance()
        {
            try
            {
                Varibles.setConnection();
                cmd = Varibles.getCommand();


                String query = "SELECT SUM(SPLR_BLNCE) as SumSPLR_BLNCE FROM merp.suppliers ;";

                cmd.CommandText = query;

                reader = cmd.ExecuteReader();

                while (reader.Read())
                {
                    try
                    {
                        splrBalance = reader.GetDouble("SumSPLR_BLNCE");
                    }
                    catch (Exception ex)
                    {
                        splrBalance = 0;
                    }
                }

                supplierBalanceTextBox.Text = splrBalance.ToString("0.00");
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            finally
            {
                reader.Close();
                Varibles.closeConnection();
            }
        }
Пример #24
0
        private void fillChildrenForms()
        {
            for (int i = 0; i < userPermTreeView.Nodes.Count; i++)
            {
                try
                {
                    Varibles.setConnection();
                    cmd = Varibles.getCommand();

                    String sqlCommand = "Select forms_name FROM merp.forms_name where form_parent = '" + i + "' ";
                    cmd.CommandText = sqlCommand;

                    reader = cmd.ExecuteReader();



                    String formName;

                    while (reader.Read())
                    {
                        formName = reader.GetString("forms_name");
                        userPermTreeView.Nodes[i].Nodes.Add(formName);
                    }

                    reader.Close();
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }
                finally
                {
                    Varibles.closeConnection();
                }
            }
        }
Пример #25
0
        private void saveBtn_Click(object sender, EventArgs e)
        {
            bool newUser = false;

            try
            {
                Varibles.setConnection();
                cmd = Varibles.getCommand();
                int    selected = Convert.ToInt32(usersComboBox.SelectedValue);
                string query    = "";
                if (selected == 0)
                {
                    query = "INSERT INTO `merp`.`users` (`USR_NAME`, `USR_PASS`) VALUES ('" + usersComboBox.Text + "' , '" + passTextBox.Text + "')";

                    newUser = true;
                }
                else
                {
                    query = "UPDATE        merp.users" +
                            " SET  USR_NAME = '" + usersComboBox.Text + "' , USR_PASS = '******' " +
                            " WHERE        ( USR_ID = '" + selected + "' )";
                }



                cmd.CommandText = query;

                cmd.ExecuteNonQuery();

                if (selected != 0)
                {
                    query = "DELETE FROM usr_prm WHERE PRMUSR_USR_ID = '" + selected + "'";

                    cmd.CommandText = query;

                    cmd.ExecuteNonQuery();
                }

                int counter = 0;
                permissionArray = new List <string>();
                for (int i = 0; i < userPermTreeView.Nodes.Count; i++)
                {
                    for (int j = 0; j < userPermTreeView.Nodes[i].Nodes.Count; j++)
                    {
                        if (userPermTreeView.Nodes[i].Nodes[j].Checked == true)
                        {
                            permissionArray.Add(Convert.ToString(counter));
                        }
                        counter++;
                    }
                }
                MessageBox.Show("تم التعديل بنجاح");
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            finally
            {
                Varibles.closeConnection();


                if (newUser)
                {
                    resetUsersNameComboBox();
                    usersComboBox.SelectedIndex = usersComboBox.Items.Count - 1;
                }

                putCheckedinTable();

                setPermissionsFalse();
                setPermissions();
            }
        }
Пример #26
0
        private void editBtn_Click(object sender, EventArgs e)
        {
            if (supplierNameComboBox.Text == "")
            {
                supplierNameComboBox.Focus(); MessageBox.Show("من فضلك إستكمل البيانات المطلوبة"); return;
            }
            ;
            if (newSupplierNameTB.Text == "")
            {
                newSupplierNameTB.Focus(); MessageBox.Show("من فضلك إستكمل البيانات المطلوبة"); return;
            }
            ;

            try
            {
                Varibles.setConnection();
                cmd = Varibles.getCommand();
                String oldsupplierName = supplierNameComboBox.Text;
                String condition       = "SPLR_NAME LIKE '" + oldsupplierName + "'";

                String sqlCommand = "Select SPLR_NAME FROM merp.suppliers "
                                    + " WHERE ( " + condition + " )";

                cmd.CommandText = sqlCommand;

                reader = cmd.ExecuteReader();


                String newSupplierName = newSupplierNameTB.Text;
                if (reader.HasRows)
                {
                    reader.Close();
                    if (newSupplierName != "" && newSupplierName != null)
                    {
                        cmd.CommandText = "UPDATE        merp.suppliers" +
                                          " SET  SPLR_NAME = '" + newSupplierName + "'"
                                          + " WHERE ( " + condition + " ) ";

                        cmd.ExecuteReader().Close();


                        MessageBox.Show("تم اجراء التعديل بنجاح");

                        newSupplierNameTB.Text = "";
                        resetClientNameComboBox();
                        supplierNameComboBox.Text = newSupplierName;
                    }
                    else
                    {
                        MessageBox.Show("لا يمكن ترك اسم المورد فارغ");
                    }
                }
                else
                {
                    reader.Close();
                    MessageBox.Show("يجب اختيار مورد اولا");
                }

                Varibles.closeConnection();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Пример #27
0
        private void removeFromStock(int pr_id, int pr_balance)
        {
            List <StockItem> stockItemsList = new List <StockItem>();

            Varibles.setConnection();
            cmd = Varibles.getCommand();
            double stock_price   = 0;
            int    stock_balance = 0;

            try
            {
                String query = "SELECT * FROM stock where stock.prod_id = '" + pr_id + "' ORDER BY stock.buy_price ASC ";

                cmd.CommandText = query;

                reader = cmd.ExecuteReader();



                while (reader.Read())
                {
                    stock_price   = reader.GetDouble("buy_price");
                    stock_balance = reader.GetInt32("count");

                    StockItem st = new StockItem(stock_balance, stock_price);
                    stockItemsList.Add(st);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            finally
            {
                reader.Close();
                Varibles.closeConnection();
            }
            bool finishReader = false;

            for (int ii = 0; ii < stockItemsList.Count; ii++)
            {
                StockItem st = stockItemsList[ii];
                stock_balance = st.getCount();
                stock_price   = st.getBuyPrice();

                int currentBlnc = 0;
                int soldCount   = 0;

                if (pr_balance > stock_balance)
                {
                    currentBlnc = stock_balance;
                    pr_balance -= stock_balance;
                    deleteFromStock(pr_id, stock_price);
                }
                else
                {
                    currentBlnc = pr_balance;
                    int new_balance = countInStock(pr_id, stock_price) - pr_balance;

                    if (new_balance == 0)
                    {
                        deleteFromStock(pr_id, stock_price);
                    }
                    else
                    {
                        updateStock(pr_id, new_balance, stock_price);
                    }

                    finishReader = true;
                }

                if (finishReader)
                {
                    break;
                }
            }
        }
Пример #28
0
        private void populateGrid()
        {
            try
            {
                Varibles.setConnection();
                cmd = Varibles.getCommand();
                String query;

                DateTime date1 = new DateTime(dtp_from.Value.Year, dtp_from.Value.Month, dtp_from.Value.Day, 0, 0, 0);

                DateTime date2 = new DateTime(dtp_to.Value.Year, dtp_to.Value.Month, dtp_to.Value.Day, 23, 59, 59);



                if (AllTypes == true)
                {
                    query = "SELECT TE_DATE, TE_IN, TE_OUT, TE_OPTITLE, TE_CMMTS FROM merp.treasuryentries " +
                            " WHERE TE_DATE >= '" + date1.ToString("yyyy-MM-dd HH:mm:ss") + "' AND TE_DATE <= '" +
                            date2.ToString("yyyy-MM-dd HH:mm:ss") + "'";
                }
                else
                {
                    query = "SELECT TE_DATE, TE_IN, TE_OUT, TE_OPTITLE, TE_CMMTS FROM merp.treasuryentries " +
                            " WHERE TE_DATE >= '" + date1.ToString("yyyy-MM-dd HH:mm:ss") + "' AND TE_DATE <= '" +
                            date2.ToString("yyyy-MM-dd HH:mm:ss") + "' AND TE_OPTYPE_ID = " + TEType;
                }

                cmd.CommandText = query;
                dGridV_InvenLog.Rows.Clear();
                reader = cmd.ExecuteReader();

                DateTime TEDate;
                Double   In, Out;
                String   TETitle, TENotes;
                Double   TotalIn = 0, TotalOut = 0, totalAll = 0;

                while (reader.Read())
                {
                    TEDate   = reader.GetDateTime("TE_DATE");
                    In       = reader.GetDouble("TE_IN");
                    Out      = reader.GetDouble("TE_OUT");
                    TETitle  = reader.GetString("TE_OPTITLE");
                    TENotes  = reader.GetString("TE_CMMTS");
                    TotalIn  = TotalIn + In;
                    TotalOut = TotalOut + Out;
                    dGridV_InvenLog.Rows.Add(TEDate, Out, In, TETitle, TENotes);
                }
                txt_TotalIn.Text  = Convert.ToString(TotalIn);
                txt_TotalOut.Text = Convert.ToString(TotalOut);

                if (checkBox1.Checked)
                {
                    totalAll        = TotalIn - TotalOut;
                    netSaleBox.Text = Convert.ToString(totalAll);
                }
                else
                {
                    netSaleBox.Text = "0";
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            finally
            {
                reader.Close();
                Varibles.closeConnection();
            }
        }
Пример #29
0
        private void addBtn_Click(object sender, EventArgs e)
        {
            try
            {
                String splr_name = supplierNameComboBox.Text;

                if (splr_name == "" || splr_name == null)
                {
                    MessageBox.Show("لا يمكن ترك اسم المورد فارغ");
                }
                else
                {
                    Varibles.setConnection();
                    cmd = Varibles.getCommand();
                    String splr_REspName = supplierRespTB.Text;
                    String splr_Email    = emailTB.Text;
                    String splr_Tele     = PhoneTB.Text;
                    String splr_mob      = mobileTB.Text;
                    String splr_adrs     = addressTB.Text;

                    double value = 0;

                    try
                    {
                        value = Convert.ToDouble(beginBalanceTB.Text);
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show("يوجد خطأ فى رصيد البداية سيتم احتساب قيمة رصيد البداية بصفر");
                        value = 0;
                    }

                    if (radioButton1.Checked)
                    {
                        value *= -1;
                    }
                    else if (radioButton2.Checked)
                    {
                    }

                    cmd.CommandText = "INSERT  merp.suppliers" +
                                      " SET SPLR_NAME = '" + splr_name + "' , SPLR_RespName = '" + splr_REspName + "' , "
                                      + " SPLR_EMAIL =  '" + splr_Email + "' , SPLR_TEL = '" + splr_Tele + "' , " +
                                      " SPLR_MOB = '" + splr_mob + "' , SPLR_ADRS = '" + splr_adrs + "' , SPLR_BLNCE = " + value;



                    cmd.ExecuteReader().Close();
                    Varibles.closeConnection();

                    resetClientNameComboBox();
                    supplierNameComboBox.Text = splr_name;

                    MessageBox.Show("تم اضافة مورد جديد بنجاح ");

                    supplierNameComboBox.Text = "";
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Пример #30
0
 public InvLog()
 {
     Varibles.setConnection();
     cmd = Varibles.getCommand();
 }