Exemplo n.º 1
0
        private PUCAccount InitializePUCObject(int pcId)
        {
            PUCAccount objPUCinfo = null;

            foreach (PUCAccount pacc in m_lstPUCAccounts)
            {
                if (pacc.PCId == pcId)
                {
                    objPUCinfo = new PUCAccount();
                    objPUCinfo.LocationCodeId = pacc.LocationCodeId;
                    //objPUCinfo.PUCLocId = pacc.PUCLocId == pacc.LocationCodeId ? Common.INT_DBNULL : pacc.PUCLocId;
                    objPUCinfo.PCLocation   = pacc.PCLocation;
                    objPUCinfo.PCId         = pacc.PCId;
                    objPUCinfo.ModifiedDate = pacc.ModifiedDate;

                    objPUCinfo.Deposits = new List <PUCDeposit>();
                    foreach (PUCDeposit pdep in pacc.Deposits)
                    {
                        objPUCinfo.Deposits.Add(pdep);
                    }
                    break;
                }
            }
            var query = from a in objPUCinfo.Deposits orderby a.Date select a;

            objPUCinfo.Deposits = (List <PUCDeposit>)query.ToList();
            return(objPUCinfo);
        }
Exemplo n.º 2
0
        private void AddPUCAccDep()
        {
            if (ValidatePUCAccDep())
            {
                if (m_objPUCAccount == null)
                {
                    m_objPUCAccount = new PUCAccount();

                    m_objPUCAccount.LocationCodeId = Convert.ToInt32(cmbLocCode.SelectedValue);
                    //m_objPUCAccount.PUCLocId = (int)cmbPUC.SelectedValue;
                    m_objPUCAccount.PCId = (int)cmbPUC.SelectedValue;
                    m_objPUCAccount.CurrentLocationId = Common.CurrentLocationId;
                    m_objPUCAccount.CreatedBy         = m_userId;
                    m_objPUCAccount.CreatedDate       = Convert.ToDateTime(Common.DATETIME_NULL);
                    m_objPUCAccount.ModifiedBy        = m_userId;
                    m_objPUCAccount.ModifiedDate      = Convert.ToDateTime(Common.DATETIME_NULL);

                    PUCDeposit objPUCdeposit = new PUCDeposit();
                    objPUCdeposit.LocationCodeId  = m_objPUCAccount.LocationCodeId;
                    objPUCdeposit.PCId            = m_objPUCAccount.PCId;
                    objPUCdeposit.RecordNo        = "-1";
                    objPUCdeposit.TransactionNo   = txtTranNo.Text.Trim();
                    objPUCdeposit.Date            = Convert.ToDateTime(dtpDepositDate.Value.ToString(Common.DATE_TIME_FORMAT));
                    objPUCdeposit.Amount          = Convert.ToDecimal(txtDepositAmount.Text.Trim());
                    objPUCdeposit.PaymentModeId   = Convert.ToInt32(cmbPaymentMode.SelectedValue);
                    objPUCdeposit.PaymentModeType = ((DataRowView)cmbPaymentMode.SelectedItem)["keyvalue1"].ToString();
                    objPUCdeposit.CreatedBy       = m_userId;
                    objPUCdeposit.ModifiedBy      = m_userId;

                    m_objPUCAccount.Deposits = new List <PUCDeposit>();
                    m_objPUCAccount.Deposits.Add(objPUCdeposit);
                }
                else
                {
                    m_objPUCAccount.ModifiedBy   = m_userId;
                    m_objPUCAccount.ModifiedDate = Convert.ToDateTime(m_objPUCAccount.ModifiedDate.ToString(Common.DATE_TIME_FORMAT));

                    PUCDeposit objPUCdeposit = new PUCDeposit();
                    objPUCdeposit.LocationCodeId  = m_objPUCAccount.LocationCodeId;
                    objPUCdeposit.PCId            = m_objPUCAccount.PCId;
                    objPUCdeposit.RecordNo        = "-1";
                    objPUCdeposit.TransactionNo   = txtTranNo.Text.Trim();
                    objPUCdeposit.Date            = Convert.ToDateTime(dtpDepositDate.Value.ToString(Common.DATE_TIME_FORMAT));
                    objPUCdeposit.Amount          = Convert.ToDecimal(txtDepositAmount.Text.Trim());
                    objPUCdeposit.PaymentModeId   = Convert.ToInt32(cmbPaymentMode.SelectedValue);
                    objPUCdeposit.PaymentModeType = ((DataRowView)cmbPaymentMode.SelectedItem)["keyvalue1"].ToString();
                    objPUCdeposit.CreatedBy       = m_userId;
                    objPUCdeposit.ModifiedBy      = m_userId;

                    m_objPUCAccount.Deposits.Add(objPUCdeposit);
                }

                m_boolSuspendEventHandler = true;
                dgvPUCAccDep.DataSource   = null;
                m_boolSuspendEventHandler = false;
                dgvPUCAccDep.DataSource   = m_objPUCAccount.Deposits;

                btnSaveDBRecord.Enabled = IsSaveAvailable;
            }
        }
Exemplo n.º 3
0
 private void ReflectPUCAcc(int pcId)
 {
     m_objPUCAccount           = InitializePUCObject(pcId);
     m_boolSuspendEventHandler = true;
     dgvPUCAccDep.DataSource   = null;
     m_boolSuspendEventHandler = false;
     dgvPUCAccDep.DataSource   = m_objPUCAccount.Deposits;
 }
Exemplo n.º 4
0
 private void btnResetUI_Click(object sender, EventArgs e)
 {
     try
     {
         //DialogResult resetresult = MessageBox.Show(Common.GetMessage("5006"), Common.GetMessage("10004"), MessageBoxButtons.YesNo, MessageBoxIcon.Question);
         //if (resetresult == DialogResult.Yes)
         {
             ResetUI();
             m_objPUCAccount  = null;
             m_lstPUCAccounts = null;
         }
     }
     catch (Exception ex)
     {
         Common.LogException(ex);
         MessageBox.Show(Common.GetMessage("10002"), Common.GetMessage("10004"), MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
Exemplo n.º 5
0
        private PUCAccount InitializePUCObject(DataGridView dgvSender)
        {
            PUCAccount objPUCinfo = null;

            if (dgvSender.SelectedCells.Count > 0)
            {
                int    pcId     = Convert.ToInt32(dgvSender.SelectedRows[0].Cells["PCId"].Value);
                string recordNo = dgvSender.SelectedRows[0].Cells["RecordNo"].Value.ToString();

                foreach (PUCAccount pacc in m_lstPUCAccounts)
                {
                    if (pacc.PCId == pcId)
                    {
                        objPUCinfo = new PUCAccount();
                        objPUCinfo.LocationCodeId = pacc.LocationCodeId;
                        objPUCinfo.LocationCode   = pacc.LocationCode;
                        //objPUCinfo.PUCLocId = pacc.PUCLocId;
                        objPUCinfo.PCLocation = pacc.PCLocation;
                        objPUCinfo.PCId       = pacc.PCId;

                        foreach (PUCDeposit pdep in pacc.Deposits)
                        {
                            if (pdep.RecordNo == recordNo)
                            {
                                objPUCinfo.Deposits = new List <PUCDeposit>();
                                objPUCinfo.Deposits.Add(pdep);
                                break;
                            }
                        }
                        break;
                    }
                }

                if (objPUCinfo != null)
                {
                    if (objPUCinfo.Deposits == null)
                    {
                        objPUCinfo = null;
                    }
                }
            }

            return(objPUCinfo);
        }
Exemplo n.º 6
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)
            {
            }
        }
Exemplo n.º 7
0
        private void dgvPUCAccDep_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
            try
            {
                DataGridView dgvSender = (DataGridView)sender;
                if ((e.RowIndex > Common.INT_DBNULL) && (e.ColumnIndex > Common.INT_DBNULL))
                {
                    string errMsg = string.Empty;
                    switch (dgvSender.Columns[e.ColumnIndex].Name)
                    {
                    case CON_GRIDCOL_EDIT:
                    {
                        ///TODO: EDIT MODE;
                        ///UNCOMMENT THE FOLLOWING COMMENTED-CODE

                        ////Check for RecordNo of the Deposit-Record
                        ////If the Deposit-Record has not yet been saved in DB,
                        ////then RecordNo would be either empty or '-1'
                        //string recordNo = m_objPUCAccount.Deposits[e.RowIndex].RecordNo.Trim();
                        //if (string.IsNullOrEmpty(recordNo) || recordNo == "-1")
                        //{
                        //    m_uisCurrentState = UIState.AddAccDep;
                        //    ManageUIState();
                        //}
                        //else
                        //{
                        //    errMsg = Common.GetMessage("VAL0108", "edit", "saved Deposit-Entry");
                        //}
                    }
                    break;

                    case CON_GRIDCOL_REMOVE:
                    {
                        //Check for RecordNo of the Deposit-Record
                        //If the Deposit-Record has not yet been saved in DB,
                        //then RecordNo would be either empty or '-1'
                        string recordNo = m_objPUCAccount.Deposits[e.RowIndex].RecordNo.Trim();
                        if (string.IsNullOrEmpty(recordNo) || recordNo == "-1")
                        {
                            DialogResult confirmresult = MessageBox.Show(Common.GetMessage("5012"), Common.GetMessage("10004"), MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                            if (confirmresult == DialogResult.Yes)
                            {
                                m_objPUCAccount.Deposits.Remove(m_objPUCAccount.Deposits[e.RowIndex]);
                                m_boolSuspendEventHandler = true;
                                dgvSender.DataSource      = null;
                                m_boolSuspendEventHandler = false;
                                if (m_objPUCAccount.Deposits.Count > 0)
                                {
                                    m_uisCurrentState    = UIState.ViewAcc;
                                    dgvSender.DataSource = m_objPUCAccount.Deposits;
                                    ManageUIState();
                                    btnSaveDBRecord.Enabled = IsSaveAvailable;
                                }
                                else
                                {
                                    m_objPUCAccount   = null;
                                    m_uisCurrentState = UIState.ResetAcc;
                                    ResetPUCAccDep();
                                    ManageUIState();
                                    btnSaveDBRecord.Enabled = false;
                                }
                            }
                        }
                        else
                        {
                            errMsg = Common.GetMessage("VAL0108", "remove", "saved Deposit-Entry");
                        }
                    }
                    break;
                    }

                    if (!string.IsNullOrEmpty(errMsg))
                    {
                        MessageBox.Show(errMsg, Common.GetMessage("10004"), MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                }
            }
            catch (Exception ex)
            {
                Common.LogException(ex);
                MessageBox.Show(Common.GetMessage("10002"), Common.GetMessage("10004"), MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }