Esempio n. 1
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;
        }
Esempio n. 2
0
 public bool DeleteSerialBookByBookNumber(string strBook_Number, string strSavedBy, DateTime dtFrom, DateTime dtTo, ref string strResponse)
 {
     bool result = false;
     strResponse = string.Empty;
     using (Promotion.DataModel.SerialResult_BO objSerialResult_BO = new SerialResult_BO())
     {
         DataModel.SerialResult objSerialResult = objSerialResult_BO.GetByBook_numberAndInput_time(strBook_Number, dtFrom, dtTo);
         if (objSerialResult != null)
         {
             string strSerials = objSerialResult.Serials;
             string[] Serials = null;
             if (strSerials.Length > 0)
             {
                 strSerials = strSerials.Substring(0, strSerials.Length - 1);
                 Serials = strSerials.Split("|".ToCharArray());
             }
             else
             {
                 ArrayList arrTmp = new ArrayList();
                 Serials = (string[])arrTmp.ToArray(typeof(string));
             }
             log.Info(strSerials);
             using (Promotion.DataModel.DelSerial_BO objDelSerial_BO = new DelSerial_BO())
             {
                 for (int nIndex = 0; nIndex < Serials.Length; nIndex++)
                 {
                     DelSerial objDelSerial = new DelSerial();
                     objDelSerial.book_number = objSerialResult.book_number;
                     objDelSerial.Serial = Serials[nIndex];
                     objDelSerial.input_time = DateTime.Now;
                     objDelSerial.SavedBy = strSavedBy;
                     objDelSerial_BO.CreateDelSerial(objDelSerial);
                     log.Info(strBook_Number + ": Xóa " + Serials[nIndex]);
                 }
             }
             objSerialResult.DeletedBy = strSavedBy;
             objSerialResult.DeletedDate = DateTime.Now;
             objSerialResult_BO.DeleteSerialResult(objSerialResult);
             result = true;
         }
         else
         {
             strResponse = string.Format("Số sổ {0} không tồn tại.", strBook_Number);
             log.Info(strResponse);
         }
     }
     return result;
 }
Esempio n. 3
0
 public bool IsSerialBookResultExisted(string strCustomer_Id, string strBook_Number, DateTime dtFrom, DateTime dtTo)
 {
     bool result = false;
     using (Promotion.DataModel.SerialResult_BO objSerialResult_BO = new SerialResult_BO())
     {
         List<Promotion.DataModel.SerialResult> lstData = objSerialResult_BO.GetByCustomer_idAndBook_numberAndInput_time(strCustomer_Id, strBook_Number, dtFrom, dtTo).ToList();
         if (lstData != null && lstData.Count > 0)
         {
             result = true;
         }
     }
     return result;
 }
Esempio n. 4
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;
 }
Esempio n. 5
0
        private void BindData()
        {
            try
            {
                if (string.IsNullOrEmpty(txtFrom.Text))
                {
                    lblMessage.Text = "Nhập ngày bắt đầu báo cáo";
                    txtFrom.Focus();
                    return;
                }

                if (string.IsNullOrEmpty(txtTo.Text))
                {
                    lblMessage.Text = "Nhập ngày kết thúc báo cáo";
                    txtTo.Focus();
                    return;
                }

                //if (string.IsNullOrEmpty(cboBranch.SelectedItem.Value))
                //{
                //    lblMessage.Text = "Chọn chi nhánh báo cáo";
                //    cboBranch.Focus();
                //    return;
                //}


                DateTime dtFrom = new DateTime();
                DateTime dtTo   = new DateTime();
                string[] arr    = null;
                int      day    = -1;
                int      month  = -1;
                int      year   = -1;
                if (!string.IsNullOrEmpty(txtFrom.Text))
                {
                    arr = txtFrom.Text.Trim().Split('/');
                    if (arr != null && arr.Length > 2)
                    {
                        int.TryParse(arr[0], out day);
                        int.TryParse(arr[1], out month);
                        int.TryParse(arr[2], out year);
                        if (day > 0 && month > 0 && year > 0)
                        {
                            dtFrom = new DateTime(year, month, day, 0, 0, 1);
                        }
                    }
                }

                if (!string.IsNullOrEmpty(txtTo.Text))
                {
                    arr = txtTo.Text.Trim().Split('/');
                    if (arr != null && arr.Length > 2)
                    {
                        int.TryParse(arr[0], out day);
                        int.TryParse(arr[1], out month);
                        int.TryParse(arr[2], out year);
                        if (day > 0 && month > 0 && year > 0)
                        {
                            dtTo = new DateTime(year, month, day, 23, 59, 59);
                        }
                    }
                }

                using (Promotion.DataModel.SerialResult_BO objSerialResult_BO = new Promotion.DataModel.SerialResult_BO())
                {
                    List <Promotion.DataModel.SerialResult> lstData = objSerialResult_BO.GetByCO_CODEAndInput_time(cboBranch.SelectedItem.Value, dtFrom, dtTo).ToList();
                    dxgvSerial.DataSource = lstData;
                    dxgvSerial.DataBind();
                }
            }
            catch (Exception ex)
            {
                log.Fatal(ex);
            }
        }
Esempio n. 6
0
        private void BindData()
        {
            try
            {
                if (string.IsNullOrEmpty(txtFrom.Text))
                {
                    lblMessage.Text = "Nhập ngày bắt đầu báo cáo";
                    txtFrom.Focus();
                    return;
                }

                if (string.IsNullOrEmpty(txtTo.Text))
                {
                    lblMessage.Text = "Nhập ngày kết thúc báo cáo";
                    txtTo.Focus();
                    return;
                }

                //if (string.IsNullOrEmpty(cboBranch.SelectedItem.Value))
                //{
                //    lblMessage.Text = "Chọn chi nhánh báo cáo";
                //    cboBranch.Focus();
                //    return;
                //}


                DateTime dtFrom = new DateTime();
                DateTime dtTo = new DateTime();
                string[] arr = null;
                int day = -1;
                int month = -1;
                int year = -1;
                if (!string.IsNullOrEmpty(txtFrom.Text))
                {
                    arr = txtFrom.Text.Trim().Split('/');
                    if (arr != null && arr.Length > 2)
                    {
                        int.TryParse(arr[0], out day);
                        int.TryParse(arr[1], out month);
                        int.TryParse(arr[2], out year);
                        if (day > 0 && month > 0 && year > 0)
                        {
                            dtFrom = new DateTime(year, month, day, 0, 0, 1);
                        }
                    }
                }

                if (!string.IsNullOrEmpty(txtTo.Text))
                {
                    arr = txtTo.Text.Trim().Split('/');
                    if (arr != null && arr.Length > 2)
                    {
                        int.TryParse(arr[0], out day);
                        int.TryParse(arr[1], out month);
                        int.TryParse(arr[2], out year);
                        if (day > 0 && month > 0 && year > 0)
                        {
                            dtTo = new DateTime(year, month, day, 23, 59, 59);
                        }
                    }
                }

                using (Promotion.DataModel.SerialResult_BO objSerialResult_BO = new Promotion.DataModel.SerialResult_BO())
                {
                    List<Promotion.DataModel.SerialResult> lstData = objSerialResult_BO.GetByCO_CODEAndInput_time(cboBranch.SelectedItem.Value, dtFrom, dtTo).ToList();
                    dxgvSerial.DataSource = lstData;
                    dxgvSerial.DataBind();
                }
            }
            catch (Exception ex)
            {
                log.Fatal(ex);
            }
        }