private void PartyName_KeyDown(object sender, KeyEventArgs e)
 {
     if (e.Key == Key.Enter)
     {
         RefNo.Focus();
     }
 }
Example #2
0
        protected override bool ValidData()
        {
            gridViewDetail.CloseEditor();
            gridViewDetail.UpdateCurrentRow();

            var endDateOfYear = DateTime.Parse("31/12/" + BasePostedDate.Year);

            if (string.IsNullOrEmpty(RefNo) || RefNo.Equals(""))
            {
                XtraMessageBox.Show(ResourceHelper.GetResourceValueByName("ResFAArmortizationRefNo"),
                                    ResourceHelper.GetResourceValueByName("ResDetailContent"), MessageBoxButtons.OK,
                                    MessageBoxIcon.Error);
                txtRefNo.Focus();
                return(false);
            }
            if (!BasePostedDate.ToShortDateString().Equals(endDateOfYear.ToShortDateString()))
            {
                XtraMessageBox.Show(ResourceHelper.GetResourceValueByName("ResFAArmortizationEndDateOfYear"),
                                    ResourceHelper.GetResourceValueByName("ResDetailContent"), MessageBoxButtons.OK,
                                    MessageBoxIcon.Error);
                txtRefNo.Focus();
                return(false);
            }
            if (FixedAssetArmortizationDetails == null || FixedAssetArmortizationDetails.Count <= 0)
            {
                XtraMessageBox.Show(ResourceHelper.GetResourceValueByName("ResFAArmortizationDetails"),
                                    ResourceHelper.GetResourceValueByName("ResDetailContent"), MessageBoxButtons.OK,
                                    MessageBoxIcon.Error);
                txtRefNo.Focus();
                return(false);
            }
            //LinhMC comment
            //var sameFixedAssetId = false;
            //for (var i = 0; i < FixedAssetArmortizationDetails.Count; i++)
            //{
            //    for (var j = i + 1; j < FixedAssetArmortizationDetails.Count; j++)
            //    {
            //        if (FixedAssetArmortizationDetails[i].FixedAssetId == FixedAssetArmortizationDetails[j].FixedAssetId)
            //        {
            //            sameFixedAssetId = true;
            //            break;
            //        }
            //    }
            //    if (!sameFixedAssetId) continue;
            //    XtraMessageBox.Show(ResourceHelper.GetResourceValueByName("ResSameFAArmortizationDetails"),
            //                        ResourceHelper.GetResourceValueByName("ResDetailContent"), MessageBoxButtons.OK,
            //                        MessageBoxIcon.Error);
            //    return false;
            //}

            //if (FixedAssetArmortizationDetails.GroupBy(n => n.FixedAssetId).Any(c => c.Count() > 1))
            //{
            //    XtraMessageBox.Show(ResourceHelper.GetResourceValueByName("ResSameFAArmortizationDetails"),
            //                        ResourceHelper.GetResourceValueByName("ResDetailContent"), MessageBoxButtons.OK,
            //                        MessageBoxIcon.Error);
            //    return false;
            //}

            int i             = 0;
            var lstRowAmounts = new List <string>();

            foreach (var fixedAssetArmortizationDetail in FixedAssetArmortizationDetails)
            {
                // bắt lỗi thiếu thông tin trong tài khoản
                if (!ValidAccountDetail(fixedAssetArmortizationDetail))
                {
                    //XtraMessageBox.Show(ResourceHelper.GetResourceValueByName("ResDetaiVoucherNotValid"), ResourceHelper.GetResourceValueByName("ResDetailContent"), MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return(false);
                }
                if (fixedAssetArmortizationDetail.AmountOC == 0)
                {
                    lstRowAmounts.Add((i + 1).ToString());
                }
                if (fixedAssetArmortizationDetail.AccountNumber == null)
                {
                    XtraMessageBox.Show(ResourceHelper.GetResourceValueByName("ResAccountNumber"),
                                        ResourceHelper.GetResourceValueByName("ResDetailContent"), MessageBoxButtons.OK,
                                        MessageBoxIcon.Error);
                    return(false);
                }

                if (fixedAssetArmortizationDetail.CorrespondingAccountNumber == null)
                {
                    XtraMessageBox.Show("Tài khoản đối ứng không được để trống!",
                                        ResourceHelper.GetResourceValueByName("ResDetailContent"), MessageBoxButtons.OK,
                                        MessageBoxIcon.Error);
                    return(false);
                }

                var isDetailValid = true;
                if (fixedAssetArmortizationDetail.DetailBy != null)
                {
                    var detailFieldNames = fixedAssetArmortizationDetail.DetailBy.Split(';');
                    detailFieldNames = detailFieldNames.Where(w => !w.Contains("ProjectId")).ToArray();
                    if (detailFieldNames.Any(t => fixedAssetArmortizationDetail.GetType().GetProperty(t) != null && fixedAssetArmortizationDetail.GetType().GetProperty(t).Name != "AccountingObjectId" && fixedAssetArmortizationDetail[t] != null))
                    {
                        isDetailValid = false;
                    }
                    if (!isDetailValid)
                    {
                        XtraMessageBox.Show(ResourceHelper.GetResourceValueByName("ResDetaiVoucherNotValid"), "Thống báo", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                        return(false);
                    }
                }

                i++;
            }
            if (lstRowAmounts.Count > 0)
            {
                if (DialogResult.No == XtraMessageBox.Show("Số tiền bằng 0 tại dòng " + string.Join(", ", lstRowAmounts.ToArray()) + ". Bạn có muốn lưu chứng từ không?",
                                                           ResourceHelper.GetResourceValueByName("ResDetailContent"), MessageBoxButtons.YesNo, MessageBoxIcon.Question))
                {
                    return(false);
                }
            }

            return(true);
        }
Example #3
0
    public string PostEntry(string BRCD, string EDT, string MID, string FL)
    {
        try
        {
            SetNo1 = ""; SetNo2 = "";
            RefNo  = BD.GetMaxRefid(BRCD, EDT, "REFID");
            RefNo  = (Convert.ToInt32(RefNo) + 1).ToString();

            //Added by amol on 09/11/2017 as per ambika madam instruction (only when payment mode is cash)
            sql     = "SELECT TOP 1 ACTIVITY FROM TEMPBATCH WHERE BRCD='" + BRCD + "' AND MID_DATE='" + conn.ConvertDate(EDT) + "' AND MID='" + MID + "' And SetNo = '0' And ACTIVITY = '3' And Amt > 0 ORDER BY SYSTEMDATE";
            sResult = conn.sExecuteScalar(sql);

            if (sResult == "3")
            {
                //For Cash Receipt set
                DT  = new DataTable();
                sql = "SELECT ID,GL,SUBGL,ACCNO,ACCNAME,CUSTNO,AMT,TRXTYPE,ACTIVITY,PMT,NR,SETNO,BRCD,MID,Convert(varchar(11),MID_DATE,120)as MID_DATE,Convert(varchar(11),SYSTEMDATE,120) SYSTEMDATE,INSTRUMENTNO,Convert(varchar(11),INSTRUMENTDATE,120)INSTRUMENTDATE,NR1 FROM TEMPBATCH WHERE BRCD='" + BRCD + "' AND MID_DATE='" + conn.ConvertDate(EDT) + "' AND MID='" + MID + "' And ACTIVITY <> '4' And Amt > 0 ORDER BY SYSTEMDATE";
                DT  = conn.GetDatatable(sql);
                if (DT.Rows.Count > 0)
                {
                    SetNo1 = BD.GetSetNo(EDT, "DaySetNo", BRCD).ToString();
                    for (int K = 0; K < DT.Rows.Count; K++)
                    {
                        Result = AZ.Authorized(EDT, EDT, Convert.ToDateTime(DT.Rows[K]["MID_DATE"]).ToString("dd/MM/yyyy"), DT.Rows[K]["GL"].ToString(), DT.Rows[K]["SUBGL"].ToString(), DT.Rows[K]["ACCNO"].ToString(), DT.Rows[K]["NR"].ToString(), DT.Rows[K]["NR1"].ToString(), DT.Rows[K]["AMT"].ToString(), DT.Rows[K]["TRXTYPE"].ToString(), DT.Rows[K]["ACTIVITY"].ToString(), DT.Rows[K]["PMT"].ToString(), SetNo1.ToString(), DT.Rows[K]["INSTRUMENTNO"].ToString(), DT.Rows[K]["INSTRUMENTDATE"].ToString(), "0", "0", "1003", "01/01/1900", BRCD, MID, "0", "0", "DDSCLOSE", DT.Rows[K]["CUSTNO"].ToString(), DT.Rows[K]["ACCNAME"].ToString(), RefNo, "0");
                        //Stage=1003 done by abhihsek for Closing blance purpose on Authorize
                    }

                    //Get All Transaction From Temporary Table (TempLnTrx)
                    sql = "SELECT * From TempLnTrx Where BrCd = '" + BRCD + "' And EntryDate = '" + conn.ConvertDate(EDT).ToString() + "' And Mid = '" + MID + "' And Amount > 0 Order By SystemDate";
                    DT  = new DataTable();
                    DT  = conn.GetDatatable(sql);
                    for (int i = 0; i < DT.Rows.Count; i++)
                    {
                        //Insert Data to Original Table Here
                        Result = ITrans.LoanTrx(BRCD, DT.Rows[i]["LoanGlCode"].ToString(), DT.Rows[i]["SubGlCode"].ToString(), DT.Rows[i]["AccountNo"].ToString(), DT.Rows[i]["HeadDesc"].ToString(), DT.Rows[i]["TrxType"].ToString(), DT.Rows[i]["Activity"].ToString(), DT.Rows[i]["Narration"].ToString(), DT.Rows[i]["Amount"].ToString(), SetNo1.ToString(), "1003", MID, "0", EDT.ToString(), RefNo.ToString());
                    }
                }

                //For Cash Payment set
                DT  = new DataTable();
                sql = "SELECT ID,GL,SUBGL,ACCNO,ACCNAME,CUSTNO,AMT,TRXTYPE,ACTIVITY,PMT,NR,SETNO,BRCD,MID,Convert(varchar(11),MID_DATE,120)as MID_DATE,Convert(varchar(11),SYSTEMDATE,120) SYSTEMDATE,INSTRUMENTNO,Convert(varchar(11),INSTRUMENTDATE,120)INSTRUMENTDATE,NR1 FROM TEMPBATCH WHERE BRCD='" + BRCD + "' AND MID_DATE='" + conn.ConvertDate(EDT) + "' AND MID='" + MID + "' And ACTIVITY = '4' And Amt > 0 ORDER BY SYSTEMDATE";
                DT  = conn.GetDatatable(sql);
                if (DT.Rows.Count > 0)
                {
                    SetNo2 = BD.GetSetNo(EDT, "DaySetNo", BRCD).ToString();
                    for (int K = 0; K < DT.Rows.Count; K++)
                    {
                        //  added by abhisheck On 29/01/2018 (Stage changed 1003 to 1001)
                        Result = AZ.Authorized(EDT, EDT, Convert.ToDateTime(DT.Rows[K]["MID_DATE"]).ToString("dd/MM/yyyy"), DT.Rows[K]["GL"].ToString(), DT.Rows[K]["SUBGL"].ToString(), DT.Rows[K]["ACCNO"].ToString(), DT.Rows[K]["NR"].ToString(), DT.Rows[K]["NR1"].ToString(), DT.Rows[K]["AMT"].ToString(), DT.Rows[K]["TRXTYPE"].ToString(), DT.Rows[K]["ACTIVITY"].ToString(), DT.Rows[K]["PMT"].ToString(), SetNo2.ToString(), DT.Rows[K]["INSTRUMENTNO"].ToString(), DT.Rows[K]["INSTRUMENTDATE"].ToString(), "0", "0", "1001", "01/01/1900", BRCD, MID, "0", "0", "DDSCLOSE", DT.Rows[K]["CUSTNO"].ToString(), DT.Rows[K]["ACCNAME"].ToString(), RefNo, "0");
                    }
                }
                SetNo1 = SetNo1 + "_" + (SetNo2 == "" ? "0" : SetNo2);
            }
            else
            {
                sql = "SELECT ID,GL,SUBGL,ACCNO,ACCNAME,CUSTNO,AMT,TRXTYPE,ACTIVITY,PMT,NR,SETNO,BRCD,MID,Convert(varchar(11),MID_DATE,120)as MID_DATE,Convert(varchar(11),SYSTEMDATE,120) SYSTEMDATE,INSTRUMENTNO,Convert(varchar(11),INSTRUMENTDATE,120)INSTRUMENTDATE,NR1 FROM TEMPBATCH WHERE BRCD='" + BRCD + "' AND MID_DATE='" + conn.ConvertDate(EDT) + "' AND MID='" + MID + "' AND SETNO = '0' And Amt > 0 ORDER BY SYSTEMDATE";
                DataTable DT = new DataTable();
                DT = conn.GetDatatable(sql);
                if (DT.Rows.Count > 0)
                {
                    SetNo1 = BD.GetSetNo(EDT, "DaySetNo", BRCD).ToString();

                    for (int K = 0; K < DT.Rows.Count; K++)
                    {
                        Result = AZ.Authorized(EDT, EDT, Convert.ToDateTime(DT.Rows[K]["MID_DATE"]).ToString("dd/MM/yyyy"), DT.Rows[K]["GL"].ToString(), DT.Rows[K]["SUBGL"].ToString(), DT.Rows[K]["ACCNO"].ToString(), DT.Rows[K]["NR"].ToString(), DT.Rows[K]["NR1"].ToString(), DT.Rows[K]["AMT"].ToString(), DT.Rows[K]["TRXTYPE"].ToString(), DT.Rows[K]["ACTIVITY"].ToString(), DT.Rows[K]["PMT"].ToString(), SetNo1.ToString(), DT.Rows[K]["INSTRUMENTNO"].ToString(), DT.Rows[K]["INSTRUMENTDATE"].ToString(), "0", "0", "1001", "01/01/1900", BRCD, MID, "0", "0", "DDSCLOSE", DT.Rows[K]["CUSTNO"].ToString(), DT.Rows[K]["ACCNAME"].ToString(), RefNo, "0");
                    }

                    //Get All Transaction From Temporary Table (TempLnTrx)
                    sql = "SELECT * From TempLnTrx Where BrCd = '" + BRCD + "' And EntryDate = '" + conn.ConvertDate(EDT).ToString() + "' And Mid = '" + MID + "' And SetNo = '0' And Amount > 0 Order By SystemDate";
                    DT  = new DataTable();
                    DT  = conn.GetDatatable(sql);
                    for (int i = 0; i < DT.Rows.Count; i++)
                    {
                        //Insert Data to Original Table Here
                        Result = ITrans.LoanTrx(BRCD, DT.Rows[i]["LoanGlCode"].ToString(), DT.Rows[i]["SubGlCode"].ToString(), DT.Rows[i]["AccountNo"].ToString(), DT.Rows[i]["HeadDesc"].ToString(), DT.Rows[i]["TrxType"].ToString(), DT.Rows[i]["Activity"].ToString(), DT.Rows[i]["Narration"].ToString(), DT.Rows[i]["Amount"].ToString(), SetNo1.ToString(), "1001", MID, "0", EDT.ToString(), RefNo.ToString());
                    }
                }

                sql = "SELECT ID,GL,SUBGL,ACCNO,ACCNAME,CUSTNO,AMT,TRXTYPE,ACTIVITY,PMT,NR,SETNO,BRCD,MID,Convert(varchar(11),MID_DATE,120)as MID_DATE,Convert(varchar(11),SYSTEMDATE,120) SYSTEMDATE,INSTRUMENTNO,Convert(varchar(11),INSTRUMENTDATE,120)INSTRUMENTDATE,NR1 FROM TEMPBATCH WHERE BRCD='" + BRCD + "' AND MID_DATE='" + conn.ConvertDate(EDT) + "' AND MID='" + MID + "' AND SETNO = '1' And Amt > 0 ORDER BY SYSTEMDATE";
                DT  = new DataTable();
                DT  = conn.GetDatatable(sql);
                if (DT.Rows.Count > 0)
                {
                    SetNo2 = BD.GetSetNo(EDT, "DaySetNo", BRCD).ToString();

                    for (int K = 0; K < DT.Rows.Count; K++)
                    {
                        Result = AZ.Authorized(EDT, EDT, Convert.ToDateTime(DT.Rows[K]["MID_DATE"]).ToString("dd/MM/yyyy"), DT.Rows[K]["GL"].ToString(), DT.Rows[K]["SUBGL"].ToString(), DT.Rows[K]["ACCNO"].ToString(), DT.Rows[K]["NR"].ToString(), DT.Rows[K]["NR1"].ToString(), DT.Rows[K]["AMT"].ToString(), DT.Rows[K]["TRXTYPE"].ToString(), DT.Rows[K]["ACTIVITY"].ToString(), DT.Rows[K]["PMT"].ToString(), SetNo2.ToString(), DT.Rows[K]["INSTRUMENTNO"].ToString(), DT.Rows[K]["INSTRUMENTDATE"].ToString(), "0", "0", "1003", "01/01/1900", BRCD, MID, "0", "0", "DDSCLOSE", DT.Rows[K]["CUSTNO"].ToString(), DT.Rows[K]["ACCNAME"].ToString(), RefNo, "0");
                    }

                    //Get All Transaction From Temporary Table (TempLnTrx)
                    sql = "SELECT * From TempLnTrx Where BrCd = '" + BRCD + "' And EntryDate = '" + conn.ConvertDate(EDT).ToString() + "' And Mid = '" + MID + "' And SetNo = '1' And Amount > 0 Order By SystemDate";
                    DT  = new DataTable();
                    DT  = conn.GetDatatable(sql);
                    for (int i = 0; i < DT.Rows.Count; i++)
                    {
                        //Insert Data to Original Table Here
                        Result = ITrans.LoanTrx(BRCD, DT.Rows[i]["LoanGlCode"].ToString(), DT.Rows[i]["SubGlCode"].ToString(), DT.Rows[i]["AccountNo"].ToString(), DT.Rows[i]["HeadDesc"].ToString(), DT.Rows[i]["TrxType"].ToString(), DT.Rows[i]["Activity"].ToString(), DT.Rows[i]["Narration"].ToString(), DT.Rows[i]["Amount"].ToString(), SetNo2.ToString(), "1003", MID, "0", EDT.ToString(), RefNo.ToString());
                    }
                }
                SetNo1 = SetNo1 + "_" + (SetNo2 == "" ? "0" : SetNo2);
            }

            sql = "DELETE FROM TEMPBATCH WHERE BRCD='" + BRCD + "' AND MID_DATE='" + conn.ConvertDate(EDT) + "' AND MID='" + MID + "'";
            conn.sExecuteQuery(sql);
            sql = "DELETE FROM TempLnTrx Where BrCd = '" + BRCD + "' And EntryDate = '" + conn.ConvertDate(EDT).ToString() + "' And Mid = '" + MID + "'";
            conn.sExecuteQuery(sql);
        }
        catch (Exception Ex)
        {
            ExceptionLogging.SendErrorToText(Ex);
        }
        return(SetNo1);
    }