protected override Boolean postValidate()
        {
            Hashtable hashDups = new Hashtable();

            MEmployeeLeave mv = (MEmployeeLeave)vw;

            int leaveMonth = CUtil.StringToInt(mv.LeaveMonth);
            int leaveYear  = CUtil.StringToInt(mv.LeaveYear);

            var items = mv.LeaveRecords;

            foreach (var item in items)
            {
                if (item.ExtFlag.Equals("D"))
                {
                    continue;
                }

                DateTime leaveDate = item.LeaveDate;

                string key = CUtil.DateTimeToDateString(leaveDate);
                if (hashDups.ContainsKey(key))
                {
                    CHelper.ShowErorMessage(leaveDate.ToString(), "ERROR_DUPLICATE_DATE", null);
                    return(false);
                }
                else
                {
                    hashDups.Add(key, key);
                }

                if ((leaveDate.Month != leaveMonth) || (leaveDate.Year != leaveYear))
                {
                    CHelper.ShowErorMessage(leaveDate.ToString(), "ERROR_NOT_IN_SAME_MONTH", null);
                    return(false);
                }

                double sum = CUtil.StringToDouble(item.AnnualLeave) +
                             CUtil.StringToDouble(item.PersonalLeave) +
                             CUtil.StringToDouble(item.ExtraLeave) + CUtil.StringToDouble(item.SickLeave);
                if (sum > 1)
                {
                    CHelper.ShowErorMessage(leaveDate.ToString(), "ERROR_LEAVE_OVER_DAY", null);
                    return(false);
                }
            }

            return(true);
        }
Пример #2
0
        protected ArrayList getColumnDataTexts(String group, int rowNum, CTable data)
        {
            ArrayList arr = (ArrayList)reportConfigHash[group];

            ArrayList temps = new ArrayList();


            foreach (CReportColConfig rc in arr)
            {
                if (rc.DataType.Equals("RN"))
                {
                    temps.Add(rowNum.ToString());
                }
                else if (rc.DataType.Equals("S"))
                {
                    temps.Add(data.GetFieldValue(rc.FieldName));
                }
                else if (rc.DataType.Equals("DT"))
                {
                    String dateStr = data.GetFieldValue(rc.FieldName).Trim();
                    String dt      = "";
                    if (!dateStr.Equals(""))
                    {
                        dt = CUtil.DateTimeToDateString(CUtil.InternalDateToDate(dateStr));
                    }
                    temps.Add(dt);
                }
                else if (rc.DataType.Equals("D"))
                {
                    String amt = CUtil.FormatNumber(data.GetFieldValue(rc.FieldName));
                    temps.Add(amt);
                }
                else if (rc.DataType.Equals("DE"))
                {
                    //Display empty if zero

                    String amt = CUtil.FormatNumber(data.GetFieldValue(rc.FieldName));
                    if (amt.Equals("0.00"))
                    {
                        amt = "";
                    }
                    temps.Add(amt);
                }
                else if (rc.DataType.Equals("DD"))
                {
                    //Display dash if zero

                    String amt = CUtil.FormatNumber(data.GetFieldValue(rc.FieldName));
                    if (amt.Equals("0.00"))
                    {
                        amt = "-";
                    }
                    temps.Add(amt);
                }
                else
                {
                    temps.Add(data.GetFieldValue(rc.FieldName));
                }
            }

            return(temps);
        }
Пример #3
0
        public override CReportDataProcessingProperty DataToProcessingProperty(CTable o, ArrayList rows, int row)
        {
            int rowcount = rows.Count;
            CReportDataProcessingProperty rpp = new CReportDataProcessingProperty();

            double[] keepTotal2 = copyTotalArray(totals);

            CRow r  = (CRow)rowdef["DATA_LEVEL1"];
            CRow nr = r.Clone();

            double amt = CUtil.StringToDouble(o.GetFieldValue("PAID_AMOUNT"));

            double newh = AvailableSpace - nr.GetHeight();

            if (newh > 0)
            {
                String pmtType  = o.GetFieldValue("PAYMENT_TYPE");
                String chequeNo = "";
                String bankName = "";
                if (pmtType.Equals("4"))
                {
                    //Cheque
                    chequeNo = o.GetFieldValue("CHEQUE_NO");
                    bankName = o.GetFieldValue("CHEQUE_TO_BANK_NAME");
                }
                else
                {
                    bankName = o.GetFieldValue("BANK_NAME");
                }

                String refDocField = "REF_PO_NO";
                if (extParam.GetFieldValue("CATEGORY").Equals("2"))
                {
                    refDocField = "REF_DOCUMENT_NO";
                }

                nr.FillColumnsText((row + 1).ToString(),
                                   CUtil.DateTimeToDateString(CUtil.InternalDateToDate(o.GetFieldValue("DOCUMENT_DATE"))),
                                   o.GetFieldValue("DOCUMENT_NO"),
                                   o.GetFieldValue(refDocField),
                                   o.GetFieldValue("ENTITY_NAME"),
                                   bankName,
                                   chequeNo,
                                   CUtil.FormatNumber(amt.ToString()));

                totals[7] = totals[7] + amt;


                rpp.AddReportRow(nr);

                if (row == rowcount - 1)
                {
                    //End row
                    CRow ft  = (CRow)rowdef["FOOTER_LEVEL1"];
                    CRow ftr = ft.Clone();

                    ftr.FillColumnsText(CLanguage.getValue("total"), "", "", "", "", "", "", CUtil.FormatNumber(totals[7].ToString()));

                    rpp.AddReportRow(ftr);
                    newh = newh - ftr.GetHeight();
                }
            }

            if (newh < 1)
            {
                rpp.IsNewPageRequired = true;

                //พวก sum ทั้งหลายจะถูกคืนค่ากลับไปด้วย เพราะถูกบวกไปแล้ว
                totals = keepTotal2;
            }
            else
            {
                AvailableSpace = newh;
            }

            return(rpp);
        }