예제 #1
0
        private void CalculateSerialByMonth(SerialBook objSerialBook)
        {
            List <SerialByMonth> arr = new List <SerialByMonth>();

            using (Promotion.DataModel.SerialByMonth_BO objSerialByMonth_BO = new SerialByMonth_BO())
            {
                arr = objSerialByMonth_BO.GetTop(36).ToList();
            }

            if (objSerialBook != null && arr != null && arr.Count > 0)
            {
                if (objSerialBook.Currency == "VND")
                {
                    int           nPart = (int)(objSerialBook.TotalAmount / arr[0].VND);
                    SerialByMonth oItem = FindSerialMonthByPeriod(objSerialBook.Period, arr);
                    if (oItem != null)
                    {
                        objSerialBook.Soluong = oItem.SoPhieu * nPart;
                    }
                }
                else
                {
                    int           nPart = (int)(objSerialBook.TotalAmount / arr[0].USD);
                    SerialByMonth oItem = FindSerialMonthByPeriod(objSerialBook.Period, arr);
                    if (oItem != null)
                    {
                        objSerialBook.Soluong = oItem.SoPhieu * nPart;
                    }
                }
            }
        }
예제 #2
0
        private void CalculateSerialByWeek(SerialBook objSerialBook, int nRemaindays)
        {
            List <SerialByWeek> arr = new List <SerialByWeek>();

            using (Promotion.DataModel.SerialByWeek_BO objSerialByWeek_BO = new SerialByWeek_BO())
            {
                arr = objSerialByWeek_BO.GetTop(36).ToList();
            }
            if (objSerialBook != null && arr != null && arr.Count > 0)
            {
                int nWeeks = nRemaindays / 7;
                if (objSerialBook.Currency == "VND")
                {
                    int          nPart = (int)(objSerialBook.TotalAmount / arr[0].VND);
                    SerialByWeek oItem = FindSerialWeekByPeriod(nWeeks, arr);
                    if (oItem != null)
                    {
                        objSerialBook.Soluong = oItem.SoPhieu * nPart;
                    }
                }
                else
                {
                    int          nPart = (int)(objSerialBook.TotalAmount / arr[0].USD);
                    SerialByWeek oItem = FindSerialWeekByPeriod(nWeeks, arr);
                    if (oItem != null)
                    {
                        objSerialBook.Soluong = oItem.SoPhieu * nPart;
                    }
                }
            }
        }
예제 #3
0
        public SerialBook GetSerialBookResultByBookNumber(string strBookNumber, DateTime dtFrom, DateTime dtTo)
        {
            SerialBook arr = new SerialBook();

            using (DataModel.SerialResult_BO objSerialResult_BO = new SerialResult_BO())
            {
                DataModel.SerialResult objSerialResult = objSerialResult_BO.GetByBook_numberAndInput_time(strBookNumber, dtFrom, dtTo);
                if (objSerialResult != null)
                {
                    arr = ConvertTo(objSerialResult);
                }
                else
                {
                    arr = null;
                }
            }
            return(arr);
        }
예제 #4
0
        public bool SaveSerialBook(string strUserName, SerialBook oBook, DateTime dtStart, DateTime dtEnd, ref string strResponse)
        {
            bool result = false;

            if (oBook == null)
            {
                strResponse = "Dữ liệu không phù hợp";
            }
            else
            {
                if (IsSerialBookResultExisted(oBook.Customer_Id, oBook.Book_Number, dtStart, dtEnd))
                {
                    strResponse = string.Format("Số sổ book_number {0} của khách hàng {1} đã tồn tại!", oBook.Customer_Id, oBook.Book_Number);
                    log.Info(strResponse);
                }
                else
                {
                    try
                    {
                        string strSerials = string.Empty;
                        foreach (string str in oBook.Masoduthuongs)
                        {
                            strSerials += str + "|";
                        }
                        int nSeq = 0;
                        using (Promotion.DataModel.LuckySerial_BO objLuckySerial_BO = new LuckySerial_BO())
                        {
                            List <Promotion.DataModel.LuckySerial> lstData = objLuckySerial_BO.GetByInputTime(dtStart, dtEnd).ToList();
                            if (lstData != null && lstData.Count > 0)
                            {
                                nSeq = lstData.Count;
                            }
                        }
                        nSeq++;

                        using (Promotion.DataModel.SerialResult_BO objSerialResult_BO = new SerialResult_BO())
                        {
                            Promotion.DataModel.SerialResult objSerialResult = new SerialResult();
                            objSerialResult.book_number   = oBook.Book_Number;
                            objSerialResult.customer_id   = oBook.Customer_Id;
                            objSerialResult.customer_name = oBook.Customer_Name;
                            objSerialResult.CMND          = oBook.CMTND;
                            objSerialResult.tel           = oBook.Telephone;
                            objSerialResult.amount        = oBook.TotalAmount;
                            objSerialResult.kyhan         = oBook.Period;
                            objSerialResult.currency      = oBook.Currency;
                            objSerialResult.Serials       = strSerials;
                            objSerialResult.Input_time    = DateTime.Now;
                            objSerialResult.SavedBy       = strUserName;
                            objSerialResult.EFFECT_DATE   = oBook.ValueDate;
                            objSerialResult.MATURITY_DATE = oBook.MaturityDate;
                            objSerialResult.Sector        = oBook.Sector;
                            objSerialResult.ACCT_NUM      = oBook.ACCOUNT_NUMBER;
                            objSerialResult.CO_CODE       = oBook.CO_CODE;
                            objSerialResult.TERM          = oBook.TERM;
                            objSerialResult.Seq           = nSeq;
                            objSerialResult.DAO_CODE      = oBook.DAO_CODE;
                            objSerialResult.DEPT_CODE     = oBook.DEPT_CODE;
                            //objSerialResult.cMoney = oBook.TERM;
                            objSerialResult_BO.CreateSerialResult(objSerialResult);
                        }
                        log.Info(strSerials);
                        result = true;
                    }
                    catch (Exception ex)
                    {
                        log.Fatal(ex);
                    }
                }
            }

            return(result);
        }
예제 #5
0
        public bool GetSerialBookByBookNumber(SerialBook objSerialBook, DateTime dtFrom, DateTime dtTo, ref string strResponse)
        {
            bool result = false;

            strResponse = string.Empty;
            if (objSerialBook == null)
            {
            }
            else
            {
                TimeSpan ts      = objSerialBook.MaturityDate - objSerialBook.ValueDate;
                int      nPeriod = (int)(ts.TotalDays / 30);
                int      nRemain = (int)(ts.TotalDays % 30);
                if (nRemain >= 28)
                {
                    nPeriod++;
                }
                objSerialBook.Period = nPeriod;

                if (objSerialBook.Period > 0)
                {
                    //month
                    CalculateSerialByMonth(objSerialBook);
                }
                else
                {
                    //week
                    CalculateSerialByWeek(objSerialBook, nRemain);
                }
                //initiate serial number
                string[]  strSerials       = GenerateSerialNumber();
                ArrayList arrMasoduthuongs = new ArrayList();
                SerialMax objSerialMax     = new SerialMax();
                using (Promotion.DataModel.SerialMax_BO objSerialMax_BO = new SerialMax_BO())
                {
                    objSerialMax = objSerialMax_BO.GetTop(1, dtFrom, dtTo).FirstOrDefault();
                }
                long lIndex = 0;
                if (objSerialMax != null)
                {
                    lIndex += objSerialMax.MaxSerial;
                }

                if ((lIndex + objSerialBook.Soluong) < Constant.MAX_SERIAL_COUNT)
                {
                    long nIdx = lIndex + objSerialBook.Soluong;
                    using (Promotion.DataModel.SerialMax_BO objSerialMax_BO = new SerialMax_BO())
                    {
                        objSerialMax = objSerialMax_BO.GetTop(1, dtFrom, dtTo).FirstOrDefault();
                        long lSerial = long.Parse(strSerials[nIdx]);
                        if (objSerialMax != null)
                        {
                            objSerialMax.MaxSerial  = lSerial;
                            objSerialMax.input_time = DateTime.Now;
                            objSerialMax_BO.UpdateSerialMax(objSerialMax);
                        }
                        else
                        {
                            objSerialMax            = new SerialMax();
                            objSerialMax.MaxSerial  = lSerial;
                            objSerialMax.input_time = DateTime.Now;
                            objSerialMax_BO.CreateSerialMax(objSerialMax);
                        }
                    }
                    for (long nIndex = (lIndex + 1); nIndex <= (lIndex + objSerialBook.Soluong); nIndex++)
                    {
                        arrMasoduthuongs.Add(strSerials[nIndex]);
                    }
                }
                else if ((lIndex + objSerialBook.Soluong) >= Constant.MAX_SERIAL_COUNT)
                {
                    List <DelSerial> arrDel = new List <DelSerial>();
                    using (Promotion.DataModel.DelSerial_BO objDelSerial_BO = new DelSerial_BO())
                    {
                        arrDel = objDelSerial_BO.GetByDatTime(dtFrom, dtTo).ToList();
                    }

                    if ((lIndex + objSerialBook.Soluong) > (Constant.MAX_SERIAL_COUNT + arrDel.Count))
                    {
                        long nRemainSerial = (Constant.MAX_SERIAL_COUNT - lIndex) + arrDel.Count;
                        strResponse = string.Format("Không đủ mã dự thưởng để cấp.Số lượng mã dự thưởng còn lại {0}, số lượng phải cấp {1}.", nRemainSerial, (objSerialBook.Soluong));
                        log.Info(strResponse);
                    }
                    using (Promotion.DataModel.SerialMax_BO objSerialMax_BO = new SerialMax_BO())
                    {
                        objSerialMax = objSerialMax_BO.GetTop(1, dtFrom, dtTo).FirstOrDefault();
                        long lSerial = long.Parse(strSerials[Constant.MAX_SERIAL_COUNT]);

                        if (objSerialMax != null)
                        {
                            objSerialMax.MaxSerial  = lSerial;
                            objSerialMax.input_time = DateTime.Now;
                            objSerialMax_BO.UpdateSerialMax(objSerialMax);
                        }
                        else
                        {
                            objSerialMax            = new SerialMax();
                            objSerialMax.MaxSerial  = lSerial;
                            objSerialMax.input_time = DateTime.Now;
                            objSerialMax_BO.CreateSerialMax(objSerialMax);
                        }
                    }
                    int nSerialCount = 0;
                    for (long i = lIndex + 1; i <= Constant.MAX_SERIAL_COUNT; i++)
                    {
                        nSerialCount++;
                        arrMasoduthuongs.Add(strSerials[i]);
                    }
                    if (nSerialCount < objSerialBook.Soluong)
                    {
                        using (Promotion.DataModel.DelSerial_BO objDelSerial_BO = new DelSerial_BO())
                        {
                            foreach (DelSerial oSerial in arrDel)
                            {
                                if (nSerialCount >= objSerialBook.Soluong)
                                {
                                    break;
                                }
                                arrMasoduthuongs.Add(oSerial.Serial);
                                objDelSerial_BO.DeleteDelSerial(oSerial.Id);
                                nSerialCount++;
                            }
                        }
                    }
                }
                objSerialBook.Masoduthuongs = (string[])arrMasoduthuongs.ToArray(typeof(string));
                result = true;
            }
            return(result);
        }
예제 #6
0
        private SerialBook ConvertTo(DataModel.SerialResult objSerialResult)
        {
            SerialBook oItem = new SerialBook();

            oItem.ID             = objSerialResult.id;
            oItem.Customer_Id    = objSerialResult.customer_id;
            oItem.Customer_Name  = objSerialResult.customer_name;
            oItem.CMTND          = objSerialResult.CMND;
            oItem.Telephone      = objSerialResult.tel;
            oItem.Book_Number    = objSerialResult.book_number;
            oItem.TotalAmount    = objSerialResult.amount.Value;
            oItem.Period         = objSerialResult.kyhan;
            oItem.Currency       = objSerialResult.currency;
            oItem.ValueDate      = objSerialResult.EFFECT_DATE.Value;
            oItem.PeriodInWord   = objSerialResult.TERM;
            oItem.MaturityDate   = objSerialResult.MATURITY_DATE.Value;
            oItem.Sector         = objSerialResult.Sector;
            oItem.TERM           = objSerialResult.TERM;
            oItem.CO_CODE        = objSerialResult.CO_CODE;
            oItem.ACCOUNT_NUMBER = objSerialResult.ACCT_NUM;
            oItem.DAO_CODE       = objSerialResult.DAO_CODE;
            oItem.ACCOUNT_NUMBER = objSerialResult.DEPT_CODE;
            try
            {
                oItem.Times = objSerialResult.Times.Value;
            }
            catch { oItem.Times = 1; }
            try
            {
                oItem.InputTime = objSerialResult.Input_time.Value;
            }
            catch { }
            try
            {
                oItem.SavedBy = objSerialResult.SavedBy;
            }
            catch
            {
            }
            //process serials
            string strSerials = objSerialResult.Serials;

            if (strSerials.Length > 0)
            {
                strSerials = strSerials.Substring(0, strSerials.Length - 1);
                string[] Serials = strSerials.Split("|".ToCharArray());
                oItem.Masoduthuongs = Serials;
            }
            else
            {
                ArrayList arrTmp = new ArrayList();
                oItem.Masoduthuongs = (string[])arrTmp.ToArray(typeof(string));
            }
            try
            {
                oItem.cMoney = objSerialResult.cMoney.Value;
            }
            catch { oItem.cMoney = 0; }
            try
            {
                oItem.Seq = objSerialResult.Seq.Value;
            }
            catch { oItem.Seq = 0; }

            return(oItem);
        }
예제 #7
0
        private SerialBook[] ConvertTo(DataTable oTable)
        {
            ArrayList arr = new ArrayList();

            if ((oTable == null) || (oTable.Rows.Count <= 0))
            {
                return((SerialBook[])arr.ToArray(typeof(SerialBook)));
            }
            foreach (DataRow oRow in oTable.Rows)
            {
                SerialBook oItem = new SerialBook();
                oItem.ID            = long.Parse(oRow["id"].ToString());
                oItem.Customer_Id   = oRow["customer_id"].ToString();
                oItem.Customer_Name = oRow["customer_name"].ToString();
                oItem.CMTND         = oRow["CMND"].ToString();
                oItem.Telephone     = oRow["tel"].ToString();
                oItem.Book_Number   = oRow["book_number"].ToString();
                oItem.TotalAmount   = double.Parse(oRow["amount"].ToString());
                oItem.Period        = int.Parse(oRow["kyhan"].ToString());
                oItem.Currency      = oRow["Currency"].ToString();
                string strValueDate = oRow["EFFECT_DATE"].ToString();
                oItem.ValueDate      = DateTime.Parse(strValueDate);
                oItem.MaturityDate   = DateTime.Parse(oRow["MATURITY_DATE"].ToString());
                oItem.Sector         = oRow["Sector"].ToString();
                oItem.TERM           = oRow["TERM"].ToString();
                oItem.CO_CODE        = oRow["CO_CODE"].ToString();
                oItem.ACCOUNT_NUMBER = oRow["ACCT_NUM"].ToString();
                try
                {
                    oItem.Times = int.Parse(oRow["Times"].ToString());//no longer using.
                }
                catch { oItem.Times = 1; }
                try
                {
                    oItem.InputTime = DateTime.Parse(oRow["Input_time"].ToString());
                }
                catch { }
                try
                {
                    oItem.SavedBy = oRow["SavedBy"].ToString();
                }
                catch
                {
                }
                //process serials
                string strSerials = oRow["Serials"].ToString();
                if (strSerials.Length > 0)
                {
                    strSerials = strSerials.Substring(0, strSerials.Length - 1);
                    string[] Serials = strSerials.Split("|".ToCharArray());
                    oItem.Masoduthuongs = Serials;
                }
                else
                {
                    ArrayList arrTmp = new ArrayList();
                    oItem.Masoduthuongs = (string[])arrTmp.ToArray(typeof(string));
                }
                try
                {
                    oItem.cMoney = int.Parse(oRow["cMoney"].ToString());
                }
                catch { oItem.cMoney = 0; }
                try
                {
                    oItem.Seq = long.Parse(oRow["seq"].ToString());
                }
                catch { oItem.Seq = 0; }
                arr.Add(oItem);
            }

            return((SerialBook[])arr.ToArray(typeof(SerialBook)));
        }
예제 #8
0
        public SerialBook GetSerialBookFromT24(string strBookNumber, string strHost, string strPort, string strService, string strUserId, string strPwd, string strSchema, string strBOOK_TYPE, string strCIF, ref string strCategory)
        {
            SerialBook oBook = null;

            //T24DataMining.DataMiningClient oClient = new T24DataMining.DataMiningClient();
            //bool bResult = false;
            //string strResponse = string.Empty;
            //bResult = oClient.Connect(strHost, strPort, strService, strUserId, strPwd, ref strResponse);
            //if (!bResult)
            //{
            //    log.Fatal(strResponse);
            //}
            //else
            //{
            //    try
            //    {
            //        string strAZCommandText = "SELECT ID,PASSBOOK.NUMBER,CUSTOMER,CURRENCY,PRINCIPAL,VALUE.DATE,MATURITY.DATE,CO.CODE,TERM FROM " + strSchema + ".";
            //        strAZCommandText += "FBNK_AZ_ACCOUNT WHERE PASSBOOK.NUMBER='" + strBookNumber + "'";

            //        string strLDCommandText = "SELECT ID,CONTRACT.NO,CUSTOMER.ID,CURRENCY,AMOUNT,VALUE.DATE,FIN.MAT.DATE,CO.CODE,TERM FROM " + strSchema + ".";
            //        strLDCommandText += "FBNK_LD_L002 WHERE CONTRACT.NO='" + strBookNumber + "'";

            //        if (strBOOK_TYPE.ToUpper() == "AZ")
            //        {
            //            strResponse = string.Empty;
            //            //DataSet ods = oClient.ExecSQL(strHost, strPort, strService, strUserId, strPwd, strAZCommandText, "", false, ref bResult, ref strResponse);
            //            DataSet ods = oClient.GetAZByCustomerID(strHost, strPort, strService, strSchema, strUserId, strPwd, strCIF, false, ref bResult, ref strResponse);
            //            if ((ods == null) || ods.Tables.Count <= 0)
            //            {

            //            }
            //            else
            //            {
            //                Commons.Convertion _oConvertion = new Commons.Convertion();
            //                DataTable oAZTable = ods.Tables[0];
            //                foreach (DataRow row in oAZTable.Rows)
            //                {
            //                    if (row["PASSBOOK.NUMBER"] != null && row["PASSBOOK.NUMBER"].ToString() == strBookNumber)
            //                    {
            //                        oBook = new SerialBook();
            //                        oBook.Book_Number = row["PASSBOOK.NUMBER"].ToString();
            //                        oBook.Customer_Id = row["CUSTOMER"].ToString();
            //                        oBook.Currency = row["CURRENCY"].ToString().ToUpper();
            //                        oBook.TotalAmount = double.Parse(row["PRINCIPAL"].ToString());
            //                        oBook.ValueDate = _oConvertion.ConvertToMMddyyyy(row["VALUE.DATE"].ToString());
            //                        oBook.MaturityDate = _oConvertion.ConvertToMMddyyyy(row["MATURITY.DATE"].ToString());
            //                        oBook.ACCOUNT_NUMBER = row["ID"].ToString();
            //                        oBook.CO_CODE = row["CO.CODE"].ToString();
            //                        if (row["THAM.GIA.KM"] != null)
            //                        {
            //                            oBook.ThamGiaKM = row["THAM.GIA.KM"].ToString();
            //                        }
            //                        if (oAZTable.Rows[0]["TERM"] != null && !string.IsNullOrEmpty(row["TERM"].ToString()))
            //                        {
            //                            oBook.TERM = row["TERM"].ToString();
            //                        }
            //                        else
            //                        {
            //                            oBook.TERM = row["ORG.TERM"].ToString();
            //                        }
            //                        strCategory = row["CATEGORY"].ToString();

            //                        //reset response
            //                        strResponse = string.Empty;
            //                        string strCustomerCommandText = "SELECT ID,NAME.1,LEGAL.ID,SECTOR,PHONE.1 FROM " + strSchema + ".FBNK_CUSTOMER WHERE ID='" + oBook.Customer_Id + "'";
            //                        DataSet oCustomerDs = oClient.ExecSQL(strHost, strPort, strService, strUserId, strPwd, strCustomerCommandText, "", false, ref bResult, ref strResponse);
            //                        if ((oCustomerDs == null) || (oCustomerDs.Tables.Count <= 0))
            //                        {

            //                        }
            //                        else
            //                        {
            //                            DataTable oCustomerTable = oCustomerDs.Tables[0];
            //                            oBook.Customer_Name = oCustomerTable.Rows[0]["NAME.1"].ToString();
            //                            oBook.CMTND = oCustomerTable.Rows[0]["LEGAL.ID"].ToString();
            //                            oBook.Sector = oCustomerTable.Rows[0]["SECTOR"].ToString();
            //                            oBook.Telephone = oCustomerTable.Rows[0]["PHONE.1"].ToString();
            //                        }
            //                        break;
            //                    }
            //                }
            //            }
            //        }
            //        else //LD
            //        {
            //            strResponse = string.Empty;
            //            DataSet ods = oClient.ExecSQL(strHost, strPort, strService, strUserId, strPwd, strLDCommandText, m_cstrStandardSelectionName, false, ref bResult, ref strResponse);
            //            if ((ods == null) || ods.Tables.Count <= 0)
            //            {
            //                log.Fatal(strResponse);
            //            }
            //            else
            //            {
            //                Commons.Convertion _oConvertion = new Commons.Convertion();
            //                DataTable oAZTable = ods.Tables[0];
            //                oBook = new SerialBook();
            //                oBook.Book_Number = oAZTable.Rows[0]["CONTRACT.NO"].ToString();
            //                oBook.Customer_Id = oAZTable.Rows[0]["CUSTOMER.ID"].ToString();
            //                oBook.Currency = oAZTable.Rows[0]["CURRENCY"].ToString().ToUpper();
            //                oBook.TotalAmount = double.Parse(oAZTable.Rows[0]["AMOUNT"].ToString());
            //                oBook.ValueDate = _oConvertion.ConvertToMMddyyyy(oAZTable.Rows[0]["VALUE.DATE"].ToString());
            //                oBook.MaturityDate = _oConvertion.ConvertToMMddyyyy(oAZTable.Rows[0]["FIN.MAT.DATE"].ToString());
            //                oBook.ACCOUNT_NUMBER = oAZTable.Rows[0]["ID"].ToString();
            //                oBook.CO_CODE = oAZTable.Rows[0]["CO.CODE"].ToString();
            //                if (oAZTable.Rows[0]["TERM"] != null && !string.IsNullOrEmpty(oAZTable.Rows[0]["TERM"].ToString()))
            //                {
            //                    oBook.TERM = oAZTable.Rows[0]["TERM"].ToString();
            //                }
            //                else
            //                {
            //                    oBook.TERM = oAZTable.Rows[0]["ORG.TERM"].ToString();
            //                }
            //                strCategory = oAZTable.Rows[0]["CATEGORY"].ToString();

            //                //reset response
            //                strResponse = string.Empty;
            //                string strCustomerCommandText = "SELECT ID,NAME.1,LEGAL.ID,SECTOR,PHONE.1 FROM " + strSchema + ".FBNK_CUSTOMER WHERE ID='" + oBook.Customer_Id + "'";
            //                DataSet oCustomerDs = oClient.ExecSQL(strHost, strPort, strService, strUserId, strPwd, strCustomerCommandText, "", false, ref bResult, ref strResponse);

            //                if ((oCustomerDs == null) || (oCustomerDs.Tables.Count <= 0))
            //                {
            //                    log.Fatal(strResponse);
            //                }
            //                else
            //                {
            //                    DataTable oCustomerTable = oCustomerDs.Tables[0];
            //                    oBook.Customer_Name = oCustomerTable.Rows[0]["NAME.1"].ToString();
            //                    oBook.CMTND = oCustomerTable.Rows[0]["LEGAL.ID"].ToString();
            //                    oBook.Sector = oCustomerTable.Rows[0]["SECTOR"].ToString();
            //                    oBook.Telephone = oCustomerTable.Rows[0]["PHONE.1"].ToString();
            //                }
            //            }
            //        }
            //    }
            //    catch (Exception oExc)
            //    {
            //        log.Fatal(oExc);
            //    }
            //    finally
            //    {
            //        oClient.Close();
            //        oClient = null;
            //    }
            //    if (oBook != null)
            //    {
            //        oBook.Customer_Name = SplitT24CustomerName(oBook.Customer_Name);
            //        TimeSpan ts = oBook.MaturityDate - oBook.ValueDate;
            //        int nPeriod = (int)(ts.TotalDays / 30);
            //        int nRemain = (int)(ts.TotalDays % 30);
            //        if (nRemain >= 28) nPeriod++;
            //        if (nPeriod > 0)
            //        {
            //            oBook.PeriodInWord = string.Format("{0} tháng.", nPeriod.ToString());
            //        }
            //        else
            //        {
            //            int nWeeks = nRemain / 7;
            //            oBook.PeriodInWord = string.Format("{0} tuần.", nWeeks.ToString());
            //        }
            //    }
            //}

            return(oBook);
        }
예제 #9
0
        private void BindingForm()
        {
            ClearForm();
            Session[Constant.PHAN_HE] = lstradPhanHe.SelectedValue;
            hdfSoSo.Value             = txtSoSo.Text.Trim();
            Function   objFunction   = new Function();
            SerialBook objSerialBook = objFunction.GetSerialBookResultByBookNumber(hdfSoSo.Value, dtStartDate, dtEndDate);

            if (objSerialBook != null)
            {
                //book is played.
                if ((objSerialBook.Masoduthuongs != null) && (objSerialBook.Masoduthuongs.Length > 0))
                {
                    lblMaDuThuongCo.Text = Common.FormatSerial(objSerialBook.Masoduthuongs.ToList());
                }
                lblMaKhachHang.Text  = objSerialBook.Customer_Id;
                lblTenKhachHang.Text = objSerialBook.Customer_Name;
                lblSoTienGui.Text    = String.Format("{0:C}", objSerialBook.TotalAmount).Replace("$", "") + " " + objSerialBook.Currency;
                lblKyHanGui.Text     = objSerialBook.Period + " tháng";
                lblvaluedate.Text    = objSerialBook.ValueDate.ToString("dd/MM/yyyy");
                lblmaturitydate.Text = objSerialBook.MaturityDate.ToString("dd/MM/yyyy");

                cmdCapPhieu.Visible = false;
                cmdInphieu.Visible  = true;
                //write quayso result to session.
                string     strQuaysoSession = cm_strQuaysSoSession + "_" + Session[Constant.USERNAME].ToString();
                QuaySoBook oBook            = ConvertSerialToQuaysoBook(objSerialBook);
                Session[strQuaysoSession]     = oBook;
                Session[Constant.SERIAL_BOOK] = objSerialBook;
            }
            else
            {
                string strBookCategory = string.Empty;
                objSerialBook = objFunction.GetSerialBookFromT24(hdfSoSo.Value, Session[Constant.PHAN_HE].ToString(), txtCIF.Text.Trim(), ref strBookCategory);

                if (objSerialBook == null)
                {
                    lblMessage.Text     = "Không tìm thấy số sổ " + hdfSoSo.Value;
                    lblMessage.CssClass = "errorMessage";
                    cmdCapPhieu.Visible = false;
                }
                else
                {
                    if (objSerialBook.Book_Number.ToUpper().Contains("GIB"))
                    {
                        if (strBookCategory != "6658")//GIB book number take part in promotion to receive a gift.
                        {
                            lblMessage.Text     = "Số sổ tiết kiệm điện tử không tham gia khuyến mại!";
                            lblMessage.CssClass = "errorMessage";
                            cmdCapPhieu.Visible = false;
                            return;
                        }
                    }


                    if (!objSerialBook.ThamGiaKM.ToUpper().Contains("TET VE LOC DEN"))
                    {
                        lblMessage.Text     = "Số sổ tiết kiệm không tham gia khuyến mại!";
                        lblMessage.CssClass = "errorMessage";
                        cmdCapPhieu.Visible = false;
                        return;
                    }

                    if (strBookCategory == "6602" || strBookCategory == "6612" || strBookCategory == "6611" || strBookCategory == "6601")
                    {
                        Session[Constant.SERIAL_BOOK] = objSerialBook;
                        if ((objSerialBook.ValueDate != null) && (objSerialBook.MaturityDate != null))
                        {
                            lblvaluedate.Text    = objSerialBook.ValueDate.ToString("dd/MM/yyyy");
                            lblmaturitydate.Text = objSerialBook.MaturityDate.ToString("dd/MM/yyyy");
                            TimeSpan ts = objSerialBook.MaturityDate - objSerialBook.ValueDate;
                            objSerialBook.Period = (int)ts.TotalDays / 30;
                            if ((ts.TotalDays % 30) >= 28)
                            {
                                objSerialBook.Period++;
                            }
                            lblKyHanGui.Text = objSerialBook.Period + " tháng";
                        }

                        lblMaKhachHang.Text  = objSerialBook.Customer_Id;
                        lblTenKhachHang.Text = objSerialBook.Customer_Name;
                        lblSoTienGui.Text    = String.Format("{0:C}", objSerialBook.TotalAmount).Replace("$", "") + " " + objSerialBook.Currency;
                        lblKyHanGui.Text     = objSerialBook.Period + " tháng";
                        if (objSerialBook.Currency == "USD" && objSerialBook.TotalAmount < Constant.MIN_AMOUNT_USD)
                        {
                            cmdCapPhieu.Visible = false;
                            lblMessage.Text     = "Sổ không được cấp mã. Số tiền gửi nhỏ hơn " + Constant.MIN_AMOUNT_USD.ToString() + " " + objSerialBook.Currency;
                            lblMessage.CssClass = "errorMessage";
                            cmdInphieu.Visible  = false;
                            cmdCapPhieu.Visible = false;

                            return;
                        }
                        if (objSerialBook.Currency == "VND" && objSerialBook.TotalAmount < Constant.MIN_AMOUNT_VND)
                        {
                            lblMessage.Text     = "Sổ không được cấp mã. Số tiền gửi nhỏ hơn " + Constant.MIN_AMOUNT_VND.ToString() + " " + objSerialBook.Currency;
                            lblMessage.CssClass = "errorMessage";
                            cmdInphieu.Visible  = false;
                            cmdCapPhieu.Visible = false;
                            return;
                        }
                        Session[Constant.SO_SO] = objSerialBook.Book_Number;
                        cmdInphieu.Visible      = false;
                        cmdCapPhieu.Visible     = true;
                    }
                    else
                    {
                        lblMessage.Text     = "Số sổ tiết kiệm không thuộc thể lệ tham gia khuyến mại!";
                        lblMessage.CssClass = "errorMessage";
                        cmdCapPhieu.Visible = false;
                    }
                }
            }
        }
예제 #10
0
        private void CalculateSerialByMonth(SerialBook objSerialBook)
        {
            List<SerialByMonth> arr = new List<SerialByMonth>();
            using (Promotion.DataModel.SerialByMonth_BO objSerialByMonth_BO = new SerialByMonth_BO())
            {
                arr = objSerialByMonth_BO.GetTop(36).ToList();
            }

            if (objSerialBook != null && arr != null && arr.Count > 0)
            {
                if (objSerialBook.Currency == "VND")
                {
                    int nPart = (int)(objSerialBook.TotalAmount / arr[0].VND);
                    SerialByMonth oItem = FindSerialMonthByPeriod(objSerialBook.Period, arr);
                    if (oItem != null)
                    {
                        objSerialBook.Soluong = oItem.SoPhieu * nPart;
                    }
                }
                else
                {
                    int nPart = (int)(objSerialBook.TotalAmount / arr[0].USD);
                    SerialByMonth oItem = FindSerialMonthByPeriod(objSerialBook.Period, arr);
                    if (oItem != null)
                    {
                        objSerialBook.Soluong = oItem.SoPhieu * nPart;
                    }
                }
            }
        }
예제 #11
0
        public bool SaveSerialBook(string strUserName, SerialBook oBook, DateTime dtStart, DateTime dtEnd, ref string strResponse)
        {
            bool result = false;
            if (oBook == null)
            {
                strResponse = "Dữ liệu không phù hợp";
            }
            else
            {
                if (IsSerialBookResultExisted(oBook.Customer_Id, oBook.Book_Number, dtStart, dtEnd))
                {
                    strResponse = string.Format("Số sổ book_number {0} của khách hàng {1} đã tồn tại!", oBook.Customer_Id, oBook.Book_Number);
                    log.Info(strResponse);
                }
                else
                {
                    try
                    {
                        string strSerials = string.Empty;
                        foreach (string str in oBook.Masoduthuongs)
                        {
                            strSerials += str + "|";
                        }
                        int nSeq = 0;
                        using (Promotion.DataModel.LuckySerial_BO objLuckySerial_BO = new LuckySerial_BO())
                        {
                            List<Promotion.DataModel.LuckySerial> lstData = objLuckySerial_BO.GetByInputTime(dtStart, dtEnd).ToList();
                            if (lstData != null && lstData.Count > 0)
                            {
                                nSeq = lstData.Count;
                            }

                        }
                        nSeq++;

                        using (Promotion.DataModel.SerialResult_BO objSerialResult_BO = new SerialResult_BO())
                        {
                            Promotion.DataModel.SerialResult objSerialResult = new SerialResult();
                            objSerialResult.book_number = oBook.Book_Number;
                            objSerialResult.customer_id = oBook.Customer_Id;
                            objSerialResult.customer_name = oBook.Customer_Name;
                            objSerialResult.CMND = oBook.CMTND;
                            objSerialResult.tel = oBook.Telephone;
                            objSerialResult.amount = oBook.TotalAmount;
                            objSerialResult.kyhan = oBook.Period;
                            objSerialResult.currency = oBook.Currency;
                            objSerialResult.Serials = strSerials;
                            objSerialResult.Input_time = DateTime.Now;
                            objSerialResult.SavedBy = strUserName;
                            objSerialResult.EFFECT_DATE = oBook.ValueDate;
                            objSerialResult.MATURITY_DATE = oBook.MaturityDate;
                            objSerialResult.Sector = oBook.Sector;
                            objSerialResult.ACCT_NUM = oBook.ACCOUNT_NUMBER;
                            objSerialResult.CO_CODE = oBook.CO_CODE;
                            objSerialResult.TERM = oBook.TERM;
                            objSerialResult.Seq = nSeq;
                            objSerialResult.DAO_CODE = oBook.DAO_CODE;
                            objSerialResult.DEPT_CODE = oBook.DEPT_CODE;
                            //objSerialResult.cMoney = oBook.TERM;
                            objSerialResult_BO.CreateSerialResult(objSerialResult);

                        }
                        log.Info(strSerials);
                        result = true;
                    }
                    catch (Exception ex)
                    {
                        log.Fatal(ex);
                    }
                }
            }

            return result;
        }
예제 #12
0
        public bool GetSerialBookByBookNumber(SerialBook objSerialBook, DateTime dtFrom, DateTime dtTo, ref string strResponse)
        {
            bool result = false;
            strResponse = string.Empty;
            if (objSerialBook == null)
            {

            }
            else
            {
                TimeSpan ts = objSerialBook.MaturityDate - objSerialBook.ValueDate;
                int nPeriod = (int)(ts.TotalDays / 30);
                int nRemain = (int)(ts.TotalDays % 30);
                if (nRemain >= 28) nPeriod++;
                objSerialBook.Period = nPeriod;

                if (objSerialBook.Period > 0)
                {
                    //month
                    CalculateSerialByMonth(objSerialBook);
                }
                else
                {
                    //week
                    CalculateSerialByWeek(objSerialBook, nRemain);
                }
                //initiate serial number 
                string[] strSerials = GenerateSerialNumber();
                ArrayList arrMasoduthuongs = new ArrayList();
                SerialMax objSerialMax = new SerialMax();
                using (Promotion.DataModel.SerialMax_BO objSerialMax_BO = new SerialMax_BO())
                {
                    objSerialMax = objSerialMax_BO.GetTop(1, dtFrom, dtTo).FirstOrDefault();
                }
                long lIndex = 0;
                if (objSerialMax != null)
                {
                    lIndex += objSerialMax.MaxSerial;
                }

                if ((lIndex + objSerialBook.Soluong) < Constant.MAX_SERIAL_COUNT)
                {
                    long nIdx = lIndex + objSerialBook.Soluong;
                    using (Promotion.DataModel.SerialMax_BO objSerialMax_BO = new SerialMax_BO())
                    {
                        objSerialMax = objSerialMax_BO.GetTop(1, dtFrom, dtTo).FirstOrDefault();
                        long lSerial = long.Parse(strSerials[nIdx]);
                        if (objSerialMax != null)
                        {
                            objSerialMax.MaxSerial = lSerial;
                            objSerialMax.input_time = DateTime.Now;
                            objSerialMax_BO.UpdateSerialMax(objSerialMax);
                        }
                        else
                        {
                            objSerialMax = new SerialMax();
                            objSerialMax.MaxSerial = lSerial;
                            objSerialMax.input_time = DateTime.Now;
                            objSerialMax_BO.CreateSerialMax(objSerialMax);
                        }
                    }
                    for (long nIndex = (lIndex + 1); nIndex <= (lIndex + objSerialBook.Soluong); nIndex++)
                    {
                        arrMasoduthuongs.Add(strSerials[nIndex]);
                    }
                }
                else if ((lIndex + objSerialBook.Soluong) >= Constant.MAX_SERIAL_COUNT)
                {
                    List<DelSerial> arrDel = new List<DelSerial>();
                    using (Promotion.DataModel.DelSerial_BO objDelSerial_BO = new DelSerial_BO())
                    {
                        arrDel = objDelSerial_BO.GetByDatTime(dtFrom, dtTo).ToList();
                    }

                    if ((lIndex + objSerialBook.Soluong) > (Constant.MAX_SERIAL_COUNT + arrDel.Count))
                    {
                        long nRemainSerial = (Constant.MAX_SERIAL_COUNT - lIndex) + arrDel.Count;
                        strResponse = string.Format("Không đủ mã dự thưởng để cấp.Số lượng mã dự thưởng còn lại {0}, số lượng phải cấp {1}.", nRemainSerial, (objSerialBook.Soluong));
                        log.Info(strResponse);
                    }
                    using (Promotion.DataModel.SerialMax_BO objSerialMax_BO = new SerialMax_BO())
                    {

                        objSerialMax = objSerialMax_BO.GetTop(1, dtFrom, dtTo).FirstOrDefault();
                        long lSerial = long.Parse(strSerials[Constant.MAX_SERIAL_COUNT]);

                        if (objSerialMax != null)
                        {
                            objSerialMax.MaxSerial = lSerial;
                            objSerialMax.input_time = DateTime.Now;
                            objSerialMax_BO.UpdateSerialMax(objSerialMax);
                        }
                        else
                        {
                            objSerialMax = new SerialMax();
                            objSerialMax.MaxSerial = lSerial;
                            objSerialMax.input_time = DateTime.Now;
                            objSerialMax_BO.CreateSerialMax(objSerialMax);
                        }
                    }
                    int nSerialCount = 0;
                    for (long i = lIndex + 1; i <= Constant.MAX_SERIAL_COUNT; i++)
                    {
                        nSerialCount++;
                        arrMasoduthuongs.Add(strSerials[i]);
                    }
                    if (nSerialCount < objSerialBook.Soluong)
                    {
                        using (Promotion.DataModel.DelSerial_BO objDelSerial_BO = new DelSerial_BO())
                        {
                            foreach (DelSerial oSerial in arrDel)
                            {
                                if (nSerialCount >= objSerialBook.Soluong)
                                {
                                    break;
                                }
                                arrMasoduthuongs.Add(oSerial.Serial);
                                objDelSerial_BO.DeleteDelSerial(oSerial.Id);
                                nSerialCount++;
                            }
                        }
                    }
                }
                objSerialBook.Masoduthuongs = (string[])arrMasoduthuongs.ToArray(typeof(string));
                result = true;
            }
            return result;
        }
예제 #13
0
        private SerialBook ConvertTo(DataModel.SerialResult objSerialResult)
        {

            SerialBook oItem = new SerialBook();
            oItem.ID = objSerialResult.id;
            oItem.Customer_Id = objSerialResult.customer_id;
            oItem.Customer_Name = objSerialResult.customer_name;
            oItem.CMTND = objSerialResult.CMND;
            oItem.Telephone = objSerialResult.tel;
            oItem.Book_Number = objSerialResult.book_number;
            oItem.TotalAmount = objSerialResult.amount.Value;
            oItem.Period = objSerialResult.kyhan;
            oItem.Currency = objSerialResult.currency;
            oItem.ValueDate = objSerialResult.EFFECT_DATE.Value;
            oItem.PeriodInWord = objSerialResult.TERM;
            oItem.MaturityDate = objSerialResult.MATURITY_DATE.Value;
            oItem.Sector = objSerialResult.Sector;
            oItem.TERM = objSerialResult.TERM;
            oItem.CO_CODE = objSerialResult.CO_CODE;
            oItem.ACCOUNT_NUMBER = objSerialResult.ACCT_NUM;
            oItem.DAO_CODE = objSerialResult.DAO_CODE;
            oItem.ACCOUNT_NUMBER = objSerialResult.DEPT_CODE;
            try
            {
                oItem.Times = objSerialResult.Times.Value;
            }
            catch { oItem.Times = 1; }
            try
            {
                oItem.InputTime = objSerialResult.Input_time.Value;
            }
            catch { }
            try
            {
                oItem.SavedBy = objSerialResult.SavedBy;
            }
            catch
            {

            }
            //process serials
            string strSerials = objSerialResult.Serials;
            if (strSerials.Length > 0)
            {
                strSerials = strSerials.Substring(0, strSerials.Length - 1);
                string[] Serials = strSerials.Split("|".ToCharArray());
                oItem.Masoduthuongs = Serials;
            }
            else
            {
                ArrayList arrTmp = new ArrayList();
                oItem.Masoduthuongs = (string[])arrTmp.ToArray(typeof(string));
            }
            try
            {
                oItem.cMoney = objSerialResult.cMoney.Value;
            }
            catch { oItem.cMoney = 0; }
            try
            {
                oItem.Seq = objSerialResult.Seq.Value;
            }
            catch { oItem.Seq = 0; }

            return oItem;
        }
예제 #14
0
        //public SerialBook GetSerialBookFromT24(string strBookNumber, string strHost, string strPort, string strService, string strUserId, string strPwd, string strSchema, string strBOOK_TYPE, string strCIF, ref string strCategory)
        public SerialBook GetSerialBookFromT24(string strBookNumber, string strBOOK_TYPE, string strCIF, ref string strCategory)
        {
            SerialBook oBook = null;
            using (PromotionEntities db = new PromotionEntities())
            {
                bool bResult = false;
                string strResponse = string.Empty;

                try
                {
                    //string strAZCommandText = "SELECT ID,PASSBOOK.NUMBER,CUSTOMER,CURRENCY,PRINCIPAL,VALUE.DATE,MATURITY.DATE,CO.CODE,TERM FROM " + strSchema + ".";
                    //strAZCommandText += "FBNK_AZ_ACCOUNT WHERE PASSBOOK.NUMBER='" + strBookNumber + "'";

                    //string strLDCommandText = "SELECT ID,CONTRACT.NO,CUSTOMER.ID,CURRENCY,AMOUNT,VALUE.DATE,FIN.MAT.DATE,CO.CODE,TERM FROM " + strSchema + ".";
                    //strLDCommandText += "FBNK_LD_L002 WHERE CONTRACT.NO='" + strBookNumber + "'";

                    if (strBOOK_TYPE.ToUpper() == "AZ")
                    {
                        strResponse = string.Empty;
                        var lstAZByCustomerID = db.AZ_ACCOUNT.Where(t => t.CUSTOMER_ID.Equals(strCIF));
                        if(lstAZByCustomerID != null)
                        {
                            foreach (var azAccount in lstAZByCustomerID)
                            {
                                Commons.Convertion _oConvertion = new Commons.Convertion();
                                if (azAccount.PASSBOOK_NUMBER != null && azAccount.PASSBOOK_NUMBER == strBookNumber)
                                {
                                    oBook = new SerialBook();
                                    oBook.Book_Number = azAccount.PASSBOOK_NUMBER;
                                    oBook.Customer_Id = azAccount.CUSTOMER_ID;
                                    oBook.Currency = azAccount.CURRENCY;
                                    oBook.TotalAmount = Convert.ToDouble(azAccount.PRINCIPAL);
                                    oBook.ValueDate = Convert.ToDateTime(azAccount.VALUE_DATE);
                                    oBook.MaturityDate = Convert.ToDateTime(azAccount.MATURITY_DATE);
                                    oBook.ACCOUNT_NUMBER = azAccount.ACCOUNT_NUMBER;
                                    oBook.CO_CODE = azAccount.CO_CODE;
                                    if (azAccount.THAM_GIA_KM != null)
                                    {
                                        oBook.ThamGiaKM = azAccount.THAM_GIA_KM;
                                    }
                                    if (azAccount.TERM != null && !string.IsNullOrEmpty(azAccount.TERM))
                                    {
                                        oBook.TERM = azAccount.TERM;
                                    }
                                    strCategory = azAccount.CATEGORY;

                                    //reset response
                                    strResponse = string.Empty;
                                    var objCust = db.CUSTOMERs.FirstOrDefault(t => t.CUSTOMER_CODE.Equals(oBook.Customer_Id));
                                    if(objCust != null)
                                    {
                                        oBook.Customer_Name = objCust.CUSTOMER_NAME;
                                        oBook.CMTND = objCust.LEGAL_ID;
                                        oBook.Sector = objCust.SECTOR;
                                        oBook.Telephone = objCust.TELEPHONE;
                                    }
                                    break;
                                }
                            }
                        }
                    }
                    else //LD
                    {
                        strResponse = string.Empty;
                        var objLD = db.AZ_ACCOUNT.SingleOrDefault(t => t.PASSBOOK_NUMBER.Equals(strBookNumber));
                        if(objLD != null)
                        {
                            Commons.Convertion _oConvertion = new Commons.Convertion();
                            oBook = new SerialBook();
                            oBook.Book_Number = objLD.PASSBOOK_NUMBER;
                            oBook.Customer_Id = objLD.CUSTOMER_ID;
                            oBook.Currency = objLD.CURRENCY;
                            oBook.TotalAmount = Convert.ToDouble(objLD.PRINCIPAL);
                            oBook.ValueDate = Convert.ToDateTime(objLD.VALUE_DATE);
                            oBook.MaturityDate = Convert.ToDateTime(objLD.MATURITY_DATE); ;
                            oBook.ACCOUNT_NUMBER = objLD.ACCOUNT_NUMBER;
                            oBook.CO_CODE = objLD.CO_CODE;
                            if (objLD.TERM != null && !string.IsNullOrEmpty(objLD.TERM))
                            {
                                oBook.TERM = objLD.TERM;
                            }
                            strCategory = objLD.CATEGORY;

                            //reset response
                            strResponse = string.Empty;
                            var objCust = db.CUSTOMERs.FirstOrDefault(t => t.CUSTOMER_CODE.Equals(oBook.Customer_Id));
                            if (objCust != null)
                            {
                                oBook.Customer_Name = objCust.CUSTOMER_NAME;
                                oBook.CMTND = objCust.LEGAL_ID;
                                oBook.Sector = objCust.SECTOR;
                                oBook.Telephone = objCust.TELEPHONE;
                            }
                        }
                    }
                }
                catch (Exception oExc)
                {
                    log.Error(oExc.Message);
                }
                if (oBook != null)
                {
                    oBook.Customer_Name = SplitT24CustomerName(oBook.Customer_Name);
                    TimeSpan ts = oBook.MaturityDate - oBook.ValueDate;
                    int nPeriod = (int)(ts.TotalDays / 30);
                    int nRemain = (int)(ts.TotalDays % 30);
                    if (nRemain >= 28) nPeriod++;
                    if (nPeriod > 0)
                    {
                        oBook.PeriodInWord = string.Format("{0} tháng.", nPeriod.ToString());
                    }
                    else
                    {
                        int nWeeks = nRemain / 7;
                        oBook.PeriodInWord = string.Format("{0} tuần.", nWeeks.ToString());
                    }
                }
            }

            return oBook;
        }
예제 #15
0
        private SerialBook[] ConvertTo(DataTable oTable)
        {
            ArrayList arr = new ArrayList();
            if ((oTable == null) || (oTable.Rows.Count <= 0))
                return (SerialBook[])arr.ToArray(typeof(SerialBook));
            foreach (DataRow oRow in oTable.Rows)
            {
                SerialBook oItem = new SerialBook();
                oItem.ID = long.Parse(oRow["id"].ToString());
                oItem.Customer_Id = oRow["customer_id"].ToString();
                oItem.Customer_Name = oRow["customer_name"].ToString();
                oItem.CMTND = oRow["CMND"].ToString();
                oItem.Telephone = oRow["tel"].ToString();
                oItem.Book_Number = oRow["book_number"].ToString();
                oItem.TotalAmount = double.Parse(oRow["amount"].ToString());
                oItem.Period = int.Parse(oRow["kyhan"].ToString());
                oItem.Currency = oRow["Currency"].ToString();
                string strValueDate = oRow["EFFECT_DATE"].ToString();
                oItem.ValueDate = DateTime.Parse(strValueDate);
                oItem.MaturityDate = DateTime.Parse(oRow["MATURITY_DATE"].ToString());
                oItem.Sector = oRow["Sector"].ToString();
                oItem.TERM = oRow["TERM"].ToString();
                oItem.CO_CODE = oRow["CO_CODE"].ToString();
                oItem.ACCOUNT_NUMBER = oRow["ACCT_NUM"].ToString();
                try
                {
                    oItem.Times = int.Parse(oRow["Times"].ToString());//no longer using.
                }
                catch { oItem.Times = 1; }
                try
                {
                    oItem.InputTime = DateTime.Parse(oRow["Input_time"].ToString());
                }
                catch { }
                try
                {
                    oItem.SavedBy = oRow["SavedBy"].ToString();
                }
                catch
                {

                }
                //process serials
                string strSerials = oRow["Serials"].ToString();
                if (strSerials.Length > 0)
                {
                    strSerials = strSerials.Substring(0, strSerials.Length - 1);
                    string[] Serials = strSerials.Split("|".ToCharArray());
                    oItem.Masoduthuongs = Serials;
                }
                else
                {
                    ArrayList arrTmp = new ArrayList();
                    oItem.Masoduthuongs = (string[])arrTmp.ToArray(typeof(string));
                }
                try
                {
                    oItem.cMoney = int.Parse(oRow["cMoney"].ToString());
                }
                catch { oItem.cMoney = 0; }
                try
                {
                    oItem.Seq = long.Parse(oRow["seq"].ToString());
                }
                catch { oItem.Seq = 0; }
                arr.Add(oItem);
            }

            return (SerialBook[])arr.ToArray(typeof(SerialBook));
        }
예제 #16
0
 public SerialBook GetSerialBookResultByBookNumber(string strBookNumber, DateTime dtFrom, DateTime dtTo)
 {
     SerialBook arr = new SerialBook();
     using (DataModel.SerialResult_BO objSerialResult_BO = new SerialResult_BO())
     {
         DataModel.SerialResult objSerialResult = objSerialResult_BO.GetByBook_numberAndInput_time(strBookNumber, dtFrom, dtTo);
         if (objSerialResult != null)
         {
             arr = ConvertTo(objSerialResult);
         }
         else
         {
             arr = null;
         }
     }
     return arr;
 }
예제 #17
0
        private void CalculateSerialByWeek(SerialBook objSerialBook, int nRemaindays)
        {
            List<SerialByWeek> arr = new List<SerialByWeek>();
            using (Promotion.DataModel.SerialByWeek_BO objSerialByWeek_BO = new SerialByWeek_BO())
            {
                arr = objSerialByWeek_BO.GetTop(36).ToList();
            }
            if (objSerialBook != null && arr != null && arr.Count > 0)
            {
                int nWeeks = nRemaindays / 7;
                if (objSerialBook.Currency == "VND")
                {
                    int nPart = (int)(objSerialBook.TotalAmount / arr[0].VND);
                    SerialByWeek oItem = FindSerialWeekByPeriod(nWeeks, arr);
                    if (oItem != null)
                    {
                        objSerialBook.Soluong = oItem.SoPhieu * nPart;
                    }
                }
                else
                {
                    int nPart = (int)(objSerialBook.TotalAmount / arr[0].USD);
                    SerialByWeek oItem = FindSerialWeekByPeriod(nWeeks, arr);
                    if (oItem != null)
                    {
                        objSerialBook.Soluong = oItem.SoPhieu * nPart;
                    }
                }
            }

        }
예제 #18
0
        //public SerialBook GetSerialBookFromT24(string strBookNumber, string strHost, string strPort, string strService, string strUserId, string strPwd, string strSchema, string strBOOK_TYPE, string strCIF, ref string strCategory)
        public SerialBook GetSerialBookFromT24(string strBookNumber, string strBOOK_TYPE, string strCIF, ref string strCategory)
        {
            SerialBook oBook = null;

            using (PromotionEntities db = new PromotionEntities())
            {
                bool   bResult     = false;
                string strResponse = string.Empty;

                try
                {
                    //string strAZCommandText = "SELECT ID,PASSBOOK.NUMBER,CUSTOMER,CURRENCY,PRINCIPAL,VALUE.DATE,MATURITY.DATE,CO.CODE,TERM FROM " + strSchema + ".";
                    //strAZCommandText += "FBNK_AZ_ACCOUNT WHERE PASSBOOK.NUMBER='" + strBookNumber + "'";

                    //string strLDCommandText = "SELECT ID,CONTRACT.NO,CUSTOMER.ID,CURRENCY,AMOUNT,VALUE.DATE,FIN.MAT.DATE,CO.CODE,TERM FROM " + strSchema + ".";
                    //strLDCommandText += "FBNK_LD_L002 WHERE CONTRACT.NO='" + strBookNumber + "'";

                    if (strBOOK_TYPE.ToUpper() == "AZ")
                    {
                        strResponse = string.Empty;
                        var lstAZByCustomerID = db.AZ_ACCOUNT.Where(t => t.CUSTOMER_ID.Equals(strCIF));
                        if (lstAZByCustomerID != null)
                        {
                            foreach (var azAccount in lstAZByCustomerID)
                            {
                                Commons.Convertion _oConvertion = new Commons.Convertion();
                                if (azAccount.PASSBOOK_NUMBER != null && azAccount.PASSBOOK_NUMBER == strBookNumber)
                                {
                                    oBook                = new SerialBook();
                                    oBook.Book_Number    = azAccount.PASSBOOK_NUMBER;
                                    oBook.Customer_Id    = azAccount.CUSTOMER_ID;
                                    oBook.Currency       = azAccount.CURRENCY;
                                    oBook.TotalAmount    = Convert.ToDouble(azAccount.PRINCIPAL);
                                    oBook.ValueDate      = Convert.ToDateTime(azAccount.VALUE_DATE);
                                    oBook.MaturityDate   = Convert.ToDateTime(azAccount.MATURITY_DATE);
                                    oBook.ACCOUNT_NUMBER = azAccount.ACCOUNT_NUMBER;
                                    oBook.CO_CODE        = azAccount.CO_CODE;
                                    if (azAccount.THAM_GIA_KM != null)
                                    {
                                        oBook.ThamGiaKM = azAccount.THAM_GIA_KM;
                                    }
                                    if (azAccount.TERM != null && !string.IsNullOrEmpty(azAccount.TERM))
                                    {
                                        oBook.TERM = azAccount.TERM;
                                    }
                                    strCategory = azAccount.CATEGORY;

                                    //reset response
                                    strResponse = string.Empty;
                                    var objCust = db.CUSTOMERs.FirstOrDefault(t => t.CUSTOMER_CODE.Equals(oBook.Customer_Id));
                                    if (objCust != null)
                                    {
                                        oBook.Customer_Name = objCust.CUSTOMER_NAME;
                                        oBook.CMTND         = objCust.LEGAL_ID;
                                        oBook.Sector        = objCust.SECTOR;
                                        oBook.Telephone     = objCust.TELEPHONE;
                                    }
                                    break;
                                }
                            }
                        }
                    }
                    else //LD
                    {
                        strResponse = string.Empty;
                        var objLD = db.AZ_ACCOUNT.SingleOrDefault(t => t.PASSBOOK_NUMBER.Equals(strBookNumber));
                        if (objLD != null)
                        {
                            Commons.Convertion _oConvertion = new Commons.Convertion();
                            oBook                = new SerialBook();
                            oBook.Book_Number    = objLD.PASSBOOK_NUMBER;
                            oBook.Customer_Id    = objLD.CUSTOMER_ID;
                            oBook.Currency       = objLD.CURRENCY;
                            oBook.TotalAmount    = Convert.ToDouble(objLD.PRINCIPAL);
                            oBook.ValueDate      = Convert.ToDateTime(objLD.VALUE_DATE);
                            oBook.MaturityDate   = Convert.ToDateTime(objLD.MATURITY_DATE);;
                            oBook.ACCOUNT_NUMBER = objLD.ACCOUNT_NUMBER;
                            oBook.CO_CODE        = objLD.CO_CODE;
                            if (objLD.TERM != null && !string.IsNullOrEmpty(objLD.TERM))
                            {
                                oBook.TERM = objLD.TERM;
                            }
                            strCategory = objLD.CATEGORY;

                            //reset response
                            strResponse = string.Empty;
                            var objCust = db.CUSTOMERs.FirstOrDefault(t => t.CUSTOMER_CODE.Equals(oBook.Customer_Id));
                            if (objCust != null)
                            {
                                oBook.Customer_Name = objCust.CUSTOMER_NAME;
                                oBook.CMTND         = objCust.LEGAL_ID;
                                oBook.Sector        = objCust.SECTOR;
                                oBook.Telephone     = objCust.TELEPHONE;
                            }
                        }
                    }
                }
                catch (Exception oExc)
                {
                    log.Error(oExc.Message);
                }
                if (oBook != null)
                {
                    oBook.Customer_Name = SplitT24CustomerName(oBook.Customer_Name);
                    TimeSpan ts      = oBook.MaturityDate - oBook.ValueDate;
                    int      nPeriod = (int)(ts.TotalDays / 30);
                    int      nRemain = (int)(ts.TotalDays % 30);
                    if (nRemain >= 28)
                    {
                        nPeriod++;
                    }
                    if (nPeriod > 0)
                    {
                        oBook.PeriodInWord = string.Format("{0} tháng.", nPeriod.ToString());
                    }
                    else
                    {
                        int nWeeks = nRemain / 7;
                        oBook.PeriodInWord = string.Format("{0} tuần.", nWeeks.ToString());
                    }
                }
            }

            return(oBook);
        }