Exemplo n.º 1
0
        private void btnAdd_Click(object sender, RoutedEventArgs e)
        {
            if (lstCurrency.SelectedIndex == -1)
            {
                glb_function.MsgBox("الرجاء اختيار العملة");
                lstCurrency.Focus();
                return;
            }
            if (lstAccNo.SelectedIndex == -1)
            {
                glb_function.MsgBox("الرجاء تحديد الحساب");
                lstAccNo.Focus();
                return;
            }
            if (lstAccName.SelectedIndex == -1)
            {
                glb_function.MsgBox("الرجاء تحديد الحساب");
                lstAccName.Focus();
                return;
            }
            if (nmbCurrValue.Value <= 0)
            {
                glb_function.MsgBox("الرجاء ادخال المبلغ");

                return;
            }

            if (txtCreditTotal.Text.Trim() == "")
            {
                txtCreditTotal.Text = "0";
            }
            if (txtDeptTotal.Text.Trim() == "")
            {
                txtDeptTotal.Text = "0";
            }

            clsJourDetail newRow = new clsJourDetail();

            newRow.clmPKid         = "";
            newRow.clmDept         = nmbDept.Value.ToString();
            newRow.clmCredit       = nmbCredit.Value.ToString();
            newRow.clmCurrValue    = nmbCurrValue.Value.ToString();
            newRow.clmCurrencyId   = lstCurrency.SelectedValue.ToString();
            newRow.clmCurrencyName = lstCurrency.Text;
            newRow.clmAccId        = lstAccName.SelectedValue.ToString();
            newRow.clmAccNo        = lstAccNo.Text;
            newRow.clmAccName      = lstAccName.Text;
            newRow.clmJourNote     = txtJourDetail.Text.Trim();
            newRow.clmExchangeRate = nmbExchangeRate.Value.ToString();
            dgvJourDetails.Items.Add(newRow);



            txtCreditTotal.Text = (Convert.ToDouble(txtCreditTotal.Text.Trim()) + Convert.ToDouble(newRow.clmCredit)).ToString();
            txtDeptTotal.Text   = (Convert.ToDouble(txtDeptTotal.Text.Trim()) + Convert.ToDouble(newRow.clmDept)).ToString();

            if (txtCreditTotal.Text.Trim() == txtDeptTotal.Text.Trim())
            {
                txtDeptTotal.Background   = Brushes.LawnGreen;
                txtCreditTotal.Background = Brushes.LawnGreen;
            }
            else
            {
                txtDeptTotal.Background   = Brushes.Red;
                txtCreditTotal.Background = Brushes.Red;
            }

            ClearDetail();
        }
Exemplo n.º 2
0
        private void GetData(string strPkid)
        {
            new glb_function().clearItems(this);

            ConnectionToMySQL cnn           = new ConnectionToMySQL();
            DataTable         dtJournalData = cnn.GetDataTable("SELECT h.Pkid, h.stat, Branch_id, jour_no, trans_name, trans_id, date_format(jour_date,'%d/%m/%Y') jour_date, jour_note,Person, " +
                                                               "  d.pkid dpkid, d.stat dstat, curr_id,(select c.curr_name from sales.currency c where c.pkid=d.curr_id) curr_name, acc_id, main_value, jour_value, exchange_Rate, jour_details, " +
                                                               " a.acc_no, a.acc_name " +
                                                               "  FROM journal_header h " +
                                                               "  join journal_details d " +
                                                               " join accounts a on(a.pkid = d.acc_id) " +
                                                               "  on(h.pkid = d.header_id) " +
                                                               "  where h.pkid =  " + strPkid + " order by d.pkid");

            bLoad = true;

            txtPkid.Text = strPkid;

            txtJourNo.Text           = dtJournalData.Rows[0]["jour_no"].ToString();
            dtpJourDate.SelectedDate = DateTime.ParseExact(dtJournalData.Rows[0]["jour_date"].ToString(), "dd/MM/yyyy", System.Globalization.CultureInfo.InvariantCulture);
            txtHeaderNote.Text       = dtJournalData.Rows[0]["jour_note"].ToString();
            txtCreditTotal.Text      = "0";
            txtDeptTotal.Text        = "0";
            for (int i = 0; i < dtJournalData.Rows.Count; i++)
            {
                clsJourDetail newRow = new clsJourDetail();

                if (Convert.ToDouble(dtJournalData.Rows[i]["main_value"].ToString()) > 0)
                {
                    newRow.clmDept      = dtJournalData.Rows[i]["main_value"].ToString();
                    newRow.clmCurrValue = dtJournalData.Rows[i]["jour_value"].ToString();
                    newRow.clmCredit    = "0";
                }

                else
                {
                    newRow.clmCredit    = (Convert.ToDouble(dtJournalData.Rows[i]["main_value"].ToString()) * -1).ToString();
                    newRow.clmCurrValue = (Convert.ToDouble(dtJournalData.Rows[i]["jour_value"].ToString()) * -1).ToString();
                    newRow.clmDept      = "0";
                }



                newRow.clmPKid = dtJournalData.Rows[i]["dpkid"].ToString();


                newRow.clmCurrencyId   = dtJournalData.Rows[i]["curr_id"].ToString();
                newRow.clmCurrencyName = dtJournalData.Rows[i]["curr_name"].ToString();
                newRow.clmAccId        = dtJournalData.Rows[i]["acc_id"].ToString();
                newRow.clmAccNo        = dtJournalData.Rows[i]["acc_no"].ToString();
                newRow.clmAccName      = dtJournalData.Rows[i]["acc_name"].ToString();

                newRow.clmJourNote     = dtJournalData.Rows[i]["jour_details"].ToString();
                newRow.clmExchangeRate = dtJournalData.Rows[i]["exchange_Rate"].ToString();

                dgvJourDetails.Items.Add(newRow);


                txtCreditTotal.Text = (Convert.ToDouble(txtCreditTotal.Text.Trim()) + Convert.ToDouble(newRow.clmCredit)).ToString();
                txtDeptTotal.Text   = (Convert.ToDouble(txtDeptTotal.Text.Trim()) + Convert.ToDouble(newRow.clmDept)).ToString();
            }



            if (txtCreditTotal.Text.Trim() == txtDeptTotal.Text.Trim())
            {
                txtDeptTotal.Background   = Brushes.LawnGreen;
                txtCreditTotal.Background = Brushes.LawnGreen;
            }
            else
            {
                txtDeptTotal.Background   = Brushes.Red;
                txtCreditTotal.Background = Brushes.Red;
            }


            if (UserTemplate.HasPrivilege("btnUpdate"))
            {
                btnUpdate.IsEnabled = true;
            }



            btnSave.IsEnabled = false;
            bLoad             = false;
        }