Exemple #1
0
        private void InitializeAndPopulateControls()
        {
            string errMsg = string.Empty;
            PUCCommonTransaction objTemp = new PUCCommonTransaction();

            FillLocationControls(PUCCommonTransaction.Locations.LocationCode, (int)Common.LocationConfigId.BO);

            DataTable dtTemp = Common.ParameterLookup(Common.ParameterType.Parameter, new ParameterFilter("POSPUCDEPOSITMODE", 0, 0, 0));

            //Remove Forex from Mode-of-Payments
            dtTemp.DefaultView.RowFilter = "KeyCode1 <> 3";
            dtTemp.DefaultView.Sort      = "KeyCode1";
            cmbPaymentMode.DataSource    = null;
            cmbPaymentMode.DataSource    = dtTemp.DefaultView.ToTable();
            cmbPaymentMode.DisplayMember = "KeyValue1";
            cmbPaymentMode.ValueMember   = "KeyCode1";

            dtpDepositDate.Format       = DateTimePickerFormat.Custom;
            dtpDepositDate.CustomFormat = Common.DTP_DATE_FORMAT;
            dtpDepositDate.MaxDate      = DateTime.Now.Date;
            dtpDepositDate.Value        = DateTime.Now.Date;
            dtpDepositDate.Checked      = false;

            dgvPUCAccDep.AutoGenerateColumns = false;
            dgvPUCAccDep.Columns.Clear();
            dgvPUCAccDep = Common.GetDataGridViewColumns(dgvPUCAccDep, Environment.CurrentDirectory + "\\App_Data\\GridViewDefinition.xml");

            dgvPUCAccounts.AutoGenerateColumns = false;
            dgvPUCAccounts.Columns.Clear();
            dgvPUCAccounts = Common.GetDataGridViewColumns(dgvPUCAccounts, Environment.CurrentDirectory + "\\App_Data\\GridViewDefinition.xml");
        }
Exemple #2
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);
        }
Exemple #3
0
        private void SavePUCAcc()
        {
            if (ValidatePUCAcc())
            {
                DialogResult saveResult = MessageBox.Show(Common.GetMessage("INF0027"), Common.GetMessage("10004"), MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                if (saveResult == DialogResult.Yes)
                {
                    string errMsg = string.Empty;
                    if (m_lstPUCAccounts == null)
                    {
                        m_lstPUCAccounts = new List <PUCAccount>();
                        m_lstPUCAccounts.Add(m_objPUCAccount);
                    }
                    else
                    {
                        foreach (PUCAccount pacc in m_lstPUCAccounts)
                        {
                            if (pacc.PCId == m_objPUCAccount.PCId)
                            {
                                pacc.Deposits = m_objPUCAccount.Deposits;
                                break;
                            }
                        }
                    }
                    PUCCommonTransaction objTransaction = new PUCCommonTransaction();
                    if (objTransaction.SavePUCInfo(m_objPUCAccount, ref errMsg))
                    {
                        MessageBox.Show(Common.GetMessage("8001"), Common.GetMessage("10004"), MessageBoxButtons.OK, MessageBoxIcon.Information);
                        m_uisCurrentState = UIState.ViewAcc;
                        ResetPUCAccDep();

                        SearchPUCAcc();
                        ReflectPUCAcc(m_objPUCAccount.PCId);
                        ManageUIState();
                        btnSaveDBRecord.Enabled = false;
                    }
                    else
                    {
                        if (errMsg.StartsWith("30001"))
                        {
                            MessageBox.Show(Common.GetMessage("30001"), Common.GetMessage("10004"), MessageBoxButtons.OK, MessageBoxIcon.Error);
                            Common.LogException(new Exception(errMsg));
                        }
                        else
                        {
                            MessageBox.Show(Common.GetMessage(errMsg), Common.GetMessage("10004"), MessageBoxButtons.OK, MessageBoxIcon.Error);
                        }

                        if (m_lstPUCAccounts != null)
                        {
                            if (m_lstPUCAccounts.Count == 1)
                            {
                                if (m_lstPUCAccounts[0].PCId == Common.INT_DBNULL)
                                {
                                    m_lstPUCAccounts = null;
                                }
                            }
                        }
                    }
                }
            }
        }
Exemple #4
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)
            {
            }
        }
Exemple #5
0
        private void FillLocationControls(PUCCommonTransaction.Locations locType, int locValue)
        {
            string errMsg = string.Empty;
            PUCCommonTransaction objTemp = new PUCCommonTransaction();

            m_boolSuspendEventHandler = true;

            switch (locType)
            {
            case PUCCommonTransaction.Locations.LocationCode:
            {
                int locTypeId = Common.INT_DBNULL;
                int locCodeId = Common.INT_DBNULL;

                locTypeId = locValue;

                cmbLocCode.DataSource = null;
                cmbPUC.DataSource     = null;
                DataTable dtPOSLocations = Common.ParameterLookup(Common.ParameterType.POSLocations, new ParameterFilter(Common.LocationCode, -1, -1, -1));
                DataRow[] rows           = dtPOSLocations.Select("LocationId = " + Common.CurrentLocationId.ToString());
                Common.BOId = rows[0]["LocationType"].ToString() == Common.LocationConfigId.BO.ToString() ? Convert.ToInt32(rows[0]["LocationId"]) : Convert.ToInt32(rows[0]["ReplenishmentId"]);
                //Common.BOId = Convert.ToInt32(rows[0]["ReplenishmentId"]) == -1 ? Convert.ToInt32(rows[0]["LocationId"]) : Convert.ToInt32(rows[0]["ReplenishmentId"]);
                Common.PCId = Convert.ToInt32(rows[0]["LocationId"]);

                DataTable dtLocations = Common.ParameterLookup(Common.ParameterType.WhgBoPucLocations, new ParameterFilter(string.Empty, Convert.ToInt32(locTypeId), Convert.ToInt32(locCodeId), 0));
                cmbLocCode.DataSource    = dtLocations;
                cmbLocCode.DisplayMember = "LOCCODE";
                cmbLocCode.ValueMember   = "LOCVAL";

                cmbLocCode.SelectedValue = Common.BOId;
                cmbLocCode.Enabled       = false;

                FillLocationControls(PUCCommonTransaction.Locations.PUCCode, Common.BOId);

                //dtLocations_PUC = Common.ParameterLookup(Common.ParameterType.WhgBoPucLocations, new ParameterFilter(string.Empty, Common.INT_DBNULL, (int)Common.LocationConfigId.PC, 0));
                //cmbPUC.DataSource = dtLocations_PUC;

                //cmbPUC.DisplayMember = "PUCCODE";
                //cmbPUC.ValueMember = "LOCVAL";

                //AutoCompleteStringCollection _batchcollection = new AutoCompleteStringCollection();

                //if (dtLocations_PUC != null)
                //    {
                //        for (int j = 0; j < dtLocations_PUC.Rows.Count; j++)
                //        {
                //            _batchcollection.Add(dtLocations_PUC.Rows[j][0].ToString());
                //        }
                //    }
                //cmbPUC.AutoCompleteMode = AutoCompleteMode.SuggestAppend;
                //cmbPUC.AutoCompleteSource = AutoCompleteSource.CustomSource;
                //cmbPUC.AutoCompleteCustomSource = _batchcollection;
            }
            break;

            case PUCCommonTransaction.Locations.PUCCode:
            {
                int locTypeId = Common.INT_DBNULL;
                int locCodeId = Common.INT_DBNULL;

                locTypeId = Convert.ToInt32(cmbLocType.SelectedValue);
                locCodeId = locValue;

                cmbPUC.DataSource = null;

                dtLocations_PUC      = Common.ParameterLookup(Common.ParameterType.WhgBoPucLocations, new ParameterFilter(string.Empty, (int)Common.LocationConfigId.PC, Convert.ToInt32(locCodeId), 0));
                cmbPUC.DataSource    = dtLocations_PUC;
                cmbPUC.DisplayMember = "PUCCODE";
                cmbPUC.ValueMember   = "LOCVAL";
            }
            break;
            }

            m_boolSuspendEventHandler = false;
        }