示例#1
0
        private bool ValidatePUCAccDep()
        {
            bool   isValid = true;
            string errMsg  = string.Empty;

            errorprovPUCValid.Clear();
            m_sbErrorMessages = new StringBuilder();

            if (Convert.ToInt32(cmbLocCode.SelectedValue) == Common.INT_DBNULL)
            {
                isValid = false;
                errMsg  = Common.GetMessage("VAL0002", lblLocCode.Text.Replace(":", "").Replace("*", ""));
                m_sbErrorMessages.AppendLine(errMsg);
                errorprovPUCValid.SetError(cmbLocCode, errMsg);
            }
            else
            {
                errorprovPUCValid.SetError(cmbLocCode, string.Empty);
            }

            if (Convert.ToInt32(cmbPUC.SelectedValue) == Common.INT_DBNULL)
            {
                isValid = false;
                errMsg  = Common.GetMessage("VAL0002", lblPUC.Text.Replace(":", "").Replace("*", ""));
                m_sbErrorMessages.AppendLine(errMsg);
                errorprovPUCValid.SetError(cmbPUC, errMsg);
            }
            else
            {
                //DataRow[] dr =  dtLocations_PUC.Select("PUCCode = " + cmbPUC.Text);
            }

            if (!dtpDepositDate.Checked)
            {
                isValid = false;
                errMsg  = Common.GetMessage("VAL0002", lblDepositDate.Text.Replace(":", "").Replace("*", ""));
                m_sbErrorMessages.AppendLine(errMsg);
                errorprovPUCValid.SetError(dtpDepositDate, errMsg);
            }
            else
            {
                errorprovPUCValid.SetError(dtpDepositDate, string.Empty);
            }

            if (Convert.ToInt32(cmbPaymentMode.SelectedValue) == Common.INT_DBNULL)
            {
                isValid = false;
                errMsg  = Common.GetMessage("VAL0002", lblPaymentMode.Text.Replace(":", "").Replace("*", ""));
                m_sbErrorMessages.AppendLine(errMsg);
                errorprovPUCValid.SetError(cmbPaymentMode, errMsg);
            }
            else
            {
                errorprovPUCValid.SetError(cmbPaymentMode, string.Empty);
            }

            if (string.IsNullOrEmpty(txtDepositAmount.Text.Trim()))
            {
                isValid = false;
                errMsg  = Common.GetMessage("VAL0001", lblDepositAmount.Text.Replace(":", "").Replace("*", ""));
                m_sbErrorMessages.AppendLine(errMsg);
                errorprovPUCValid.SetError(txtDepositAmount, errMsg);
            }
            else if (!Validators.IsValidAmount(txtDepositAmount.Text.Trim()))
            {
                try
                {
                    if (Convert.ToInt32(txtDepositAmount.Text.Trim()) < 0)
                    {
                        string errorMessage = "";

                        int    locCode = Common.INT_DBNULL;
                        int    pcId    = Common.INT_DBNULL;
                        int    price;
                        string transNo = txtTranNo.Text.Trim();
                        string date;

                        date    = dtpDepositDate.Value.ToString();
                        locCode = (int)cmbLocCode.SelectedValue;
                        pcId    = (int)cmbPUC.SelectedValue;
                        price   = (Convert.ToInt32(txtDepositAmount.Text));


                        PUCCommonTransaction objPUCInfo = new PUCCommonTransaction();
                        DataTable            dtPUCInfo  = objPUCInfo.FetchPUCInfo(locCode, pcId, Convert.ToInt32(cmbPaymentMode.SelectedValue), transNo, date, 1, price, ref errorMessage);
                        if (dtPUCInfo.Rows.Count > 0)
                        {
                            isValid = true;
                        }
                        else
                        {
                            isValid = false;
                        }
                    }
                    else
                    {
                        isValid = false;
                        errMsg  = Common.GetMessage("VAL0081", lblDepositAmount.Text.Replace(":", "").Replace("*", ""));
                        m_sbErrorMessages.AppendLine(errMsg);
                        errorprovPUCValid.SetError(txtDepositAmount, errMsg);
                    }
                }
                catch (Exception ex)
                {
                    throw ex;
                }
            }
            else if (Convert.ToDecimal(txtDepositAmount.Text.Trim()) == 0)
            {
                isValid = false;
                errMsg  = Common.GetMessage("VAL0081", lblDepositAmount.Text.Replace(":", "").Replace("*", ""));
                m_sbErrorMessages.AppendLine(errMsg);
                errorprovPUCValid.SetError(txtDepositAmount, errMsg);
            }
            else
            {
                errorprovPUCValid.SetError(txtDepositAmount, string.Empty);
            }

            if (m_sbErrorMessages.Length > 0)
            {
                MessageBox.Show(m_sbErrorMessages.ToString(), Common.GetMessage("10004"), MessageBoxButtons.OK, MessageBoxIcon.Error);
            }

            return(isValid);
        }
示例#2
0
        private void SearchPUCAcc()
        {
            try
            {
                if (ValidateSearchCriteria())
                {
                    string errorMessage = "";

                    int    locCode = Common.INT_DBNULL;
                    int    pcId    = Common.INT_DBNULL;
                    string transNo = txtTranNo.Text.Trim();
                    string date;
                    if (dtpDepositDate.Checked == true)
                    {
                        date = dtpDepositDate.Value.ToString();
                    }
                    else
                    {
                        date = Common.DATETIME_NULL.ToString();
                    }
                    locCode = (int)cmbLocCode.SelectedValue;
                    if (Convert.ToInt32(cmbPUC.SelectedValue) != Common.INT_DBNULL)
                    {
                        pcId = (int)cmbPUC.SelectedValue;
                    }

                    PUCCommonTransaction objPUCInfo = new PUCCommonTransaction();
                    DataTable            dtPUCInfo  = objPUCInfo.FetchPUCInfo(locCode, pcId, Convert.ToInt32(cmbPaymentMode.SelectedValue), transNo, date, 0, 0, ref errorMessage);

                    if (string.IsNullOrEmpty(errorMessage))
                    {
                        if (dtPUCInfo != null)
                        {
                            if (dtPUCInfo.Rows.Count > 0)
                            {
                                if (m_objPUCAccount == null)
                                {
                                    m_objPUCAccount = new PUCAccount();
                                }

                                m_lstPUCAccounts = new List <PUCAccount>();

                                DataTable dtTemp = dtPUCInfo.Copy();

                                dtPUCInfo.DefaultView.Sort = "PCId,DepositMode";
                                dtPUCInfo = dtPUCInfo.DefaultView.ToTable();
                                DataTable dtPUCIds = dtPUCInfo.DefaultView.ToTable(true, "LOCCODE", "LOCCODEID", "PCId", "PUCLocation", "AvailableAmount", "MODIFIEDDATE", "UsedAmount");

                                DataColumn dcColToAdd = new DataColumn("GridRowNo", typeof(int));
                                dtPUCIds.Columns.Add(dcColToAdd);
                                dtPUCIds.AcceptChanges();

                                int tempRowNo = 0;
                                foreach (DataRow dtRow in dtPUCIds.Rows)
                                {
                                    dtRow["GridRowNo"] = tempRowNo++;
                                }

                                foreach (DataRow drPCId in dtPUCIds.Rows)
                                {
                                    m_objPUCAccount = new PUCAccount();
                                    m_objPUCAccount.LocationCodeId = Convert.ToInt32(drPCId["LOCCODEID"]);
                                    m_objPUCAccount.LocationCode   = drPCId["LOCCODE"].ToString();
                                    //m_objPUCAccount.PUCLocId = Convert.ToInt32(drPCId["PUCLOCID"]);
                                    m_objPUCAccount.PCId         = Convert.ToInt32(drPCId["PCId"]);
                                    m_objPUCAccount.PCLocation   = drPCId["PUCLOCATION"].ToString();
                                    m_objPUCAccount.ModifiedDate = Convert.ToDateTime(drPCId["MODIFIEDDATE"].ToString());
                                    m_objPUCAccount.UsedAmount   = Math.Round(Convert.ToDecimal(drPCId["UsedAmount"]), Common.DisplayAmountRounding, MidpointRounding.AwayFromZero);

                                    dtPUCInfo.DefaultView.RowFilter = string.Empty;
                                    dtPUCInfo.DefaultView.RowFilter = "PCId = " + m_objPUCAccount.PCId;
                                    DataTable dtPUCInfo_Temp = dtPUCInfo.DefaultView.ToTable();
                                    m_objPUCAccount.Deposits = new List <PUCDeposit>();
                                    foreach (DataRow drPUCInfo in dtPUCInfo_Temp.Rows)
                                    {
                                        PUCDeposit pucaccdeposit = new PUCDeposit();
                                        pucaccdeposit.Amount          = Convert.ToDecimal(drPUCInfo["DEPOSITAMOUNT"]);
                                        pucaccdeposit.Date            = Convert.ToDateTime(drPUCInfo["DEPOSITDATE"]);
                                        pucaccdeposit.RecordNo        = drPUCInfo["RECORDNO"].ToString();
                                        pucaccdeposit.TransactionNo   = drPUCInfo["TRANSACTIONNO"].ToString();
                                        pucaccdeposit.PaymentModeId   = Convert.ToInt32(drPUCInfo["DEPOSITMODE"]);
                                        pucaccdeposit.PaymentModeType = drPUCInfo["DEPOSITTYPE"].ToString();

                                        m_objPUCAccount.Deposits.Add(pucaccdeposit);
                                    }

                                    m_lstPUCAccounts.Add(m_objPUCAccount);
                                }

                                dtPUCInfo.DefaultView.RowFilter = string.Empty;
                                dtPUCInfo.DefaultView.Sort      = string.Empty;
                                dtPUCInfo = dtTemp.Copy();

                                dtTemp.Dispose();
                                dtTemp = null;

                                System.Globalization.NumberFormatInfo nfi = new System.Globalization.NumberFormatInfo();
                                nfi.PercentDecimalDigits = Common.DisplayAmountRounding;
                                string strRoundingZeroesFormat = Common.GetRoundingZeroes(Common.DisplayAmountRounding); //"0.00";
                                foreach (DataRow drRow in dtPUCInfo.Rows)
                                {
                                    drRow["AVAILABLEAMOUNT"] = Convert.ToDecimal(drRow["AVAILABLEAMOUNT"]).ToString(strRoundingZeroesFormat, nfi);
                                    drRow["DEPOSITAMOUNT"]   = Convert.ToDecimal(drRow["DEPOSITAMOUNT"]).ToString(strRoundingZeroesFormat, nfi);
                                }
                                dtPUCInfo.AcceptChanges();

                                m_boolSuspendEventHandler = true;
                                dgvPUCAccounts.DataSource = m_lstPUCAccounts;//dtPUCInfo;
                                m_boolSuspendEventHandler = false;
                                if (dgvPUCAccounts.Rows.Count > 0)
                                {
                                    m_uisCurrentState = UIState.ViewAcc;
                                    ReflectPUCAcc(Convert.ToInt32(dgvPUCAccounts.Rows[0].Cells["PCId"].Value.ToString()));
                                    ManageUIState();
                                }
                            }
                            else
                            {
                                m_objPUCAccount = null;
                                MessageBox.Show(Common.GetMessage("8002"), Common.GetMessage("10004"), MessageBoxButtons.OK, MessageBoxIcon.Error);
                            }
                        }
                        else
                        {
                            m_objPUCAccount = null;
                            MessageBox.Show(Common.GetMessage("8002"), Common.GetMessage("10004"), MessageBoxButtons.OK, MessageBoxIcon.Error);
                        }
                    }
                    else
                    {
                        MessageBox.Show(errorMessage, Common.GetMessage("10004"), MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                }
                else
                {
                    MessageBox.Show(m_sbErrorMessages.ToString(), Common.GetMessage("10004"), MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
            catch (Exception ex)
            {
            }
        }