Exemple #1
0
        public void TestDateFalse()
        {
            var    v         = new CheckDate();
            string dateFalse = "20181010";

            Assert.IsFalse(v.checkDateFormat(dateFalse));
        }
Exemple #2
0
        private void btnSearchBetWeen_Click(object sender, EventArgs e)
        {
            string dateStr1 = txtBeginDateBetween1.Text;
            string dateStr2 = txtBeginDateBetween2.Text;


            string fld = " havedidlog_checkeddate ";

            txtBeginDateBetween1_TextChanged(null, null);
            if (!CheckDate.checkDate(dateStr1))
            {
                MessageBox.Show("تاریخ اولی معتبر نیست");
                return;
            }
            if (!CheckDate.checkDate(dateStr1))
            {
                MessageBox.Show("تاریخ دومی معتبر نیست");
                return;
            }

            DateTime date1 = RMX_TOOLS.date.DateXFormer.persianToGreGorian(dateStr1);
            DateTime date2 = RMX_TOOLS.date.DateXFormer.persianToGreGorian(dateStr2);

            string date1Str = date1.Year + "/" + date1.Month + "/" + date1.Day;
            string date2Str = date2.Year + "/" + date2.Month + "/" + date2.Day;

            _condition = fld + " BETWEEN '" + date1Str + " " +
                         RMX_TOOLS.date.DateConstants.BEGIN_OF_DAY + "' and '" +
                         date2Str + " " + RMX_TOOLS.date.DateConstants.END_OF_DAY + "' ";

            string cancel = "";// " and(cancel is null or cancel = 0)";

            fillGrid(_condition + cancel);
        }
Exemple #3
0
        public void TestDateReal()
        {
            var    v        = new CheckDate();
            string dateTrue = "2018-10-10";

            Assert.IsTrue(v.checkDateFormat(dateTrue));
        }
        public void Test_Nhap_Sai_Ngay_2()
        {
            searchDG  test_search = new searchDG();
            string    cbbox       = "NGAYSINH";
            string    txtbox      = "32/12/2019";
            CheckDate date        = new CheckDate();

            Assert.IsTrue(date.Check_Date(txtbox) == "Ngày không hợp lệ");
        }
        public override bool IsValid(object value)
        {
            DateTime CheckDate;

            if (DateTime.TryParse(value.ToString(), out CheckDate))
            {
                return(CheckDate.AddYears(TempMinimumAge) < DateTime.Now);
            }
            return(false);
        }
Exemple #6
0
 /// <summary>
 /// Gets the hash code
 /// </summary>
 /// <returns>Hash code</returns>
 public override int GetHashCode()
 {
     unchecked // Overflow is fine, just wrap
     {
         var hashCode = 41;
         // Suitable nullity checks etc, of course :)
         if (FirstName != null)
         {
             hashCode = hashCode * 59 + FirstName.GetHashCode();
         }
         if (LastName != null)
         {
             hashCode = hashCode * 59 + LastName.GetHashCode();
         }
         if (CompanyName != null)
         {
             hashCode = hashCode * 59 + CompanyName.GetHashCode();
         }
         if (DepartmentDocumentNumber != null)
         {
             hashCode = hashCode * 59 + DepartmentDocumentNumber.GetHashCode();
         }
         if (CheckNumber != null)
         {
             hashCode = hashCode * 59 + CheckNumber.GetHashCode();
         }
         if (CheckAmount != null)
         {
             hashCode = hashCode * 59 + CheckAmount.GetHashCode();
         }
         if (CheckDate != null)
         {
             hashCode = hashCode * 59 + CheckDate.GetHashCode();
         }
         if (TransmittalNumber != null)
         {
             hashCode = hashCode * 59 + TransmittalNumber.GetHashCode();
         }
         if (TransmittalStatus != null)
         {
             hashCode = hashCode * 59 + TransmittalStatus.GetHashCode();
         }
         if (DepositNumber != null)
         {
             hashCode = hashCode * 59 + DepositNumber.GetHashCode();
         }
         if (CashListing != null)
         {
             hashCode = hashCode * 59 + CashListing.GetHashCode();
         }
         return(hashCode);
     }
 }
        private void button4_Click(object sender, EventArgs e)
        {
            String creationFrom = txtCreationFrom.Text;
            String creationTo   = txtcreationTo.Text;
            String updateFrom   = txtUpdateFrom.Text;
            String updateTo     = txtUpdateTo.Text;

            String endDateFrom = txtEndDateFrom.Text;
            String endDateTo   = txtEndDateTo.Text;

            if ((!isDateEmpty(creationFrom) && !CheckDate.checkDate(creationFrom)) ||
                (!isDateEmpty(creationTo) && !CheckDate.checkDate(creationTo)))
            {
                MessageBox.Show("تاریخ ایجاد صحیح نمی باشد");
                return;
            }


            string cond   = getDateCondition("creationdate", creationFrom, creationTo);
            string cond2  = getDateCondition("lastupdatedate", updateFrom, updateTo);
            string cond3  = getDateCondition("EndDate", endDateFrom, endDateTo);
            string result = cond;

            if (result.Length > 0 && cond2 != null && cond2.Length > 0)
            {
                result += " and";
            }
            result += cond2;

            if (result.Length > 0 && cond3 != null && cond3.Length > 0)
            {
                result += " and";
            }
            result += cond3;

            if (birthDateHasValue.Checked)
            {
                if (result.Length > 0)
                {
                    result += " and ";
                }
                result += " (Birthdate is not null and len(BirthDate) > 0)  ";
            }
            if (mobileNumberHasValue.Checked)
            {
                if (result.Length > 0)
                {
                    result += " and ";
                }
                result += " (MobileNumber is not null and len(MobileNumber) > 0)  ";
            }
            fillGrid(result);
        }
        public void Test_Nhap_sai_dinh_dang_ngay()
        {
            searchDG test_search = new searchDG();
            string   cbbox       = "NGAYNHAP";
            string   txtbox      = "30/02/2019";//31 ky tu

            CheckDate date      = new CheckDate();
            string    actual1   = date.Check_Date(txtbox);
            string    expected1 = "Ngày không hợp lệ";

            Assert.AreEqual(expected1, actual1);

            string actual2   = test_search.search_1(cbbox, txtbox);
            string expected2 = "select * from tblDocGia";

            Assert.AreEqual(expected2, actual2);
        }
        public void Test_Nhap_sai_dinh_dang_nam()
        {
            Search_Book test_search = new Search_Book();
            string      cbbox       = "NAMXB";
            string      txtbox      = "aaaa";//31 ky tu

            CheckDate date      = new CheckDate();
            string    actual1   = date.Check_Year(txtbox);
            string    expected1 = "Năm không hợp lệ";

            Assert.AreEqual(expected1, actual1);

            string actual2   = test_search.search_1(cbbox, txtbox);
            string expected2 = "select * from tblSach";

            Assert.AreEqual(expected2, actual2);
        }//1919 2119
        private void btnSearchBetWeen_Click(object sender, EventArgs e)
        {
            string dateStr1 = txtBeginDateBetween1.Text;
            string dateStr2 = txtBeginDateBetween2.Text;

            string condition = "";
            string fld;

            fld = ViewInsuranceInfoData.endDate_FIELD;

            txtBeginDateBetween1_TextChanged(null, null);
            if (!CheckDate.checkDate(dateStr1))
            {
                MessageBox.Show("تاریخ اولی معتبر نیست");
                return;
            }
            if (!CheckDate.checkDate(dateStr1))
            {
                MessageBox.Show("تاریخ دومی معتبر نیست");
                return;
            }

            DateTime date1 = RMX_TOOLS.date.DateXFormer.persianToGreGorian(dateStr1);
            DateTime date2 = RMX_TOOLS.date.DateXFormer.persianToGreGorian(dateStr2);

            IDataProvider dp = Config.provider;


            if (rBtnHaveDid.Checked)
            {
                condition = dp.getBetweenDate(fld, date1, date2, null);
            }
            else if (rBtnOP.Checked)
            {
                condition = dp.getBetweenDate(fld, date1, date2, ViewInsuranceInfoData.DAYSBEFOREXP_FIELD);
            }

            int v = (cbxHaveDid3.Checked ? 1 : 0);

            //  condition += " and " + ViewInsuranceInfoData.haveDid_FIELD + "=" + v + " ";
            _condition = condition;
            string cancel = "";// " and(cancel is null or cancel = 0)";

            fillGrid(_condition + cancel);
        }
        private string checkData()
        {
            string tmp;

            tmp = txtName.Text;
            if (tmp == null || tmp.Trim().Length <= 0)
            {
                return("لطفا نام را وارد کنید");
            }
            tmp = txtFamily.Text;
            if (tmp == null || tmp.Trim().Length <= 0)
            {
                return("لطفا نام خانوادگی را وارد کنید");
            }
            tmp = txtInsuranceNumber.Text;
            if (tmp == null || tmp.Trim().Length <= 0)
            {
                return("لطفا شماره بیمه را وارد کنید");
            }
            int indx = cmbCondition.SelectedIndex;

            if (indx == 0)
            {
                return("لطفا نوع بیمه را وارد کنید");
            }
            if (txtBeginDate.Text.Trim().Length <= 0)
            {
                return("لطفا تاریخ شروع را وارد کنید");
            }
            if (txtEndDate.Text.Trim().Length <= 0)
            {
                return("لطفا تاریخ پایان را وارد کنید");
            }
            if (!CheckDate.checkDate(txtBeginDate.Text))
            {
                return("تاریخ شروع معتبر نیست");
            }
            if (!CheckDate.checkDate(txtEndDate.Text))
            {
                return("تاریخ پایان معتبر نیست");
            }

            return(null);
        }
        public void Test_Nhap_Dung_Thong_Tin_Tim_Kiem_5()
        {
            searchDG  test_search = new searchDG();
            string    cbbox       = "NGAYSINH";
            string    txtbox      = "28/02/2019";
            CheckDate date        = new CheckDate();

            if (date.Check_Date(txtbox) == "Ngày không hợp lệ")
            {
                Assert.Fail();
            }

            string actual = test_search.search_1(cbbox, txtbox);


            string expected = "select*from tblDocGia where " + cbbox + " like '%" + date.Check_Date(txtbox) + "%'";

            Assert.AreEqual(expected, actual);
        }
Exemple #13
0
        public object stringToValue(string str)
        {
            int d = 12;
            int m = 0;
            int y = 0;

            Boolean chk = CheckDate.checkDate(str, ref y, ref m, ref d);

            if (!chk)
            {
                return(null);
            }
            DateTime persianDateDime  = new DateTime(y, m, d, new PersianCalendar());
            DateTime greorianDateTime =
                new DateTime(gcal.GetYear(persianDateDime),
                             gcal.GetMonth(persianDateDime),
                             gcal.GetDayOfMonth(persianDateDime), new GregorianCalendar());

            return(greorianDateTime);
        }
Exemple #14
0
        private void btnSearch_Click(object sender, EventArgs e)
        {
            if (dataMode == NEW_MODE)
            {
                MessageBox.Show("هنگام ثبت جدید جستجو غیر فعال است");
                return;
            }
            string condition = "";

            if (_searchField == null || _searchField.Length <= 0)
            {
                return;
            }
            string fld = _searchField.Substring(3).ToLower().Trim();

            if (cmbSearch.Text.IndexOf("date") > 0)
            {
                int     d = 0;
                int     m = 0;
                int     y = 0;
                Boolean b = CheckDate.checkDate(cmbSearch.Text, ref y, ref m, ref d);
                if (b)
                {
                    DateTime dt = RMX_TOOLS.date.DateXFormer.persianToGreGorian(cmbSearch.Text);
                    condition = fld + "=" + dt.ToString();
                }
                else
                {
                    MessageBox.Show("تاریخ معتبر نیست");
                }
            }
            else
            {
                condition = fld + " like '%" + cmbSearch.Text + "%'";
            }

            fillGrid(condition);
            dataGridView1_SelectionChanged(null, null);
        }
Exemple #15
0
 void Start()
 {
     Instance = this;
     if (!PlayerPrefs.HasKey("ContinuousDay"))
         PlayerPrefs.SetInt("ContinuousDay", 0);
 }
Exemple #16
0
        private string checkData()
        {
            string tmp;

            tmp = txtName.Text;
            if (tmp == null || tmp.Trim().Length <= 0)
            {
                txtName.Focus();
                return("لطفا نام را وارد کنید");
            }
            tmp = txtFamily.Text;
            if (tmp == null || tmp.Trim().Length <= 0)
            {
                txtFamily.Focus();
                return("لطفا نام خانوادگی را وارد کنید");
            }
            tmp = txtInsuranceNumber.Text;
            if (tmp == null || tmp.Trim().Length <= 0)
            {
                txtInsuranceNumber.Focus();
                return("لطفا شماره بیمه را وارد کنید");
            }
            if (cmbInsuranceType.SelectedIndex < 0)
            {
                cmbInsuranceType.Focus();
                return("لطفا نوع بیمه را وارد کنید");
            }
            if (txtBeginDate.Text.Trim().Length <= 0)
            {
                txtBeginDate.Focus();
                return("لطفا تاریخ شروع را وارد کنید");
            }
            if (!CheckDate.checkDate(txtBeginDate.Text))
            {
                txtBeginDate.Focus();
                return("تاریخ شروع معتبر نیست");
            }
            if (txtEndDate.Text.Trim().Length <= 0)
            {
                txtEndDate.Focus();
                return("لطفا تاریخ اتمام را وارد کنید");
            }
            if (!CheckDate.checkDate(txtEndDate.Text))
            {
                txtEndDate.Focus();
                return("تاریخ اتمام معتبر نیست");
            }
            if (cmbCustomerType.SelectedIndex < 0)
            {
                return("نوع مشتری را وارد نمایید!");
            }

            string dateEmpty = "    /  /";

            //if (cmbCustomerType.SelectedIndex == 1 && txtBirthDate.Text == dateEmpty)
            //{
            //    return "برای ";
            //}
            if (txtBirthDate.Text != dateEmpty && !CheckDate.checkDate(txtBirthDate.Text))
            {
                txtBirthDate.Focus();
                return("تاریخ تولد معتبر نیست");
            }

            string mm = txtMobilePhone.Text;

            if (mm != null && mm.Length > 0)
            {
                if (mm.Length != 11)
                {
                    return("شماره موبایل وارده شده بایستی 11 رقم باشد");
                }
                if (mm.Substring(0, 2) != "09")
                {
                    return("موبایل وارد شده معتبر نیست");
                }
            }
            if (cmbCustomerType.SelectedIndex == 0)
            {
                //  tmp = txtPhoneNumber.Text;
                // if (tmp == null || tmp.Trim().Length <= 0)
                //{
                //   txtInsuranceNumber.Focus();
                //    return "شماره تلفن برای نوع مشتری حقیقی اجباری است";
                //}
                tmp = txtMobilePhone.Text;
                if (tmp == null || tmp.Trim().Length <= 0)
                {
                    txtMobilePhone.Focus();
                    return("شماره موبایل برای نوع مشتری حقیقی اجباری است");
                }
            }

            return(null);
        }
Exemple #17
0
        private void btnUpdate_Click(object sender, EventArgs e)
        {
            string check = checkData();

            if (check != null)
            {
                MessageBox.Show(check);
                return;
            }
            if (dataMode == EDIT_MODE)
            {
                if (dataGridView1.CurrentRow.Selected)
                {
                    if (cbxHaveDid.Checked)
                    {
                        cbxHaveDid.Checked = Boolean.Parse(_gridTools.getCurrentRowValue(InsuranceInfoData.haveDid_FIELD).ToString());
                    }
                }
            }
            if (dataMode == NEW_MODE)
            {
                cbxHaveDid.Checked = false;
            }
            if (dataGridView1.RowCount <= 0)
            {
                dataMode = NEW_MODE;
            }
            InsuranceInfoBS   isb    = new InsuranceInfoBS();
            InsuranceInfoData inData = new InsuranceInfoData();
            DataRow           dr     = inData.Tables[InsuranceInfoData.insuranceInfo_TABLE].NewRow();

            dr[InsuranceInfoData.name_FIELD]            = txtName.Text.Trim();
            dr[InsuranceInfoData.family_FIELD]          = txtFamily.Text.Trim();
            dr[InsuranceInfoData.phoneNumber_FIELD]     = txtPhoneNumber.Text.Trim();
            dr[InsuranceInfoData.insuranceNumber_FIELD] = txtInsuranceNumber.Text.Trim();

            dr[InsuranceInfoData.haveDid_FIELD]     = cbxHaveDid.Checked;
            dr[InsuranceInfoData.address_FIELD]     = txtAddress.Text.Trim();
            dr[InsuranceInfoData.description_FIELD] = txtDescription.Text.Trim();

            dr[InsuranceInfoData.mobileNumber_FIELD] = txtMobilePhone.Text.Trim();
            dr[InsuranceInfoData.CustomerType_FIELD] = cmbCustomerType.SelectedIndex;

            if (!dataMode.Equals(NEW_MODE))
            {
                dr[InsuranceInfoData.id_FIELD] = _gridTools.getCurrentRowValue(InsuranceInfoData.id_FIELD);
            }
            // Date validation and converion
            #region dateValidation
            GregorianCalendar gcal = new GregorianCalendar();
            int d = 12;
            int m = 0;
            int y = 0;
            CheckDate.checkDate(txtBeginDate.Text, ref y, ref m, ref d);
            DateTime persianDateDime  = new DateTime(y, m, d, new PersianCalendar());
            DateTime greorianDateTime =
                new DateTime(gcal.GetYear(persianDateDime),
                             gcal.GetMonth(persianDateDime),
                             gcal.GetDayOfMonth(persianDateDime), new GregorianCalendar());

            dr[InsuranceInfoData.beginDate_FIELD] = greorianDateTime;

            //
            CheckDate.checkDate(txtEndDate.Text, ref y, ref m, ref d);
            persianDateDime  = new DateTime(y, m, d, new PersianCalendar());
            greorianDateTime =
                new DateTime(gcal.GetYear(persianDateDime),
                             gcal.GetMonth(persianDateDime),
                             gcal.GetDayOfMonth(persianDateDime), new GregorianCalendar());

            dr[InsuranceInfoData.endDate_FIELD] = greorianDateTime;
            //

            //Creation Date
            String   todayShamsi;
            String[] dateArr;
            CheckDate.checkDate(txtCreationDate.Text, ref y, ref m, ref d);
            if (dataMode.Equals(NEW_MODE))
            {
                todayShamsi = RMX_TOOLS.date.DateXFormer.gregorianToPersianString(DateTime.Now);
                dateArr     = todayShamsi.Split('/');

                persianDateDime = new DateTime(int.Parse(dateArr[0]),
                                               int.Parse(dateArr[1]),
                                               int.Parse(dateArr[2]), new PersianCalendar());
            }
            else
            {
                persianDateDime = new DateTime(y, m, d, new PersianCalendar());
            }
            greorianDateTime =
                new DateTime(gcal.GetYear(persianDateDime),
                             gcal.GetMonth(persianDateDime),
                             gcal.GetDayOfMonth(persianDateDime), new GregorianCalendar());

            dr[InsuranceInfoData.creationDate_FIELD] = greorianDateTime;
            //
            //Last update date
            todayShamsi = RMX_TOOLS.date.DateXFormer.gregorianToPersianString(DateTime.Now);
            dateArr     = todayShamsi.Split('/');

            persianDateDime = new DateTime(int.Parse(dateArr[0]),
                                           int.Parse(dateArr[1]),
                                           int.Parse(dateArr[2]), new PersianCalendar());
            greorianDateTime =
                new DateTime(gcal.GetYear(persianDateDime),
                             gcal.GetMonth(persianDateDime),
                             gcal.GetDayOfMonth(persianDateDime), new GregorianCalendar());

            dr[InsuranceInfoData.lastUpdateDate_FIELD] = greorianDateTime;
            //
            //Birth date
            if (txtBirthDate.Text.Trim() != DateConstants.NULL_Date.Trim())
            {
                CheckDate.checkDate(txtBirthDate.Text, ref y, ref m, ref d);
                persianDateDime  = new DateTime(y, m, d, new PersianCalendar());
                greorianDateTime =
                    new DateTime(gcal.GetYear(persianDateDime),
                                 gcal.GetMonth(persianDateDime),
                                 gcal.GetDayOfMonth(persianDateDime), new GregorianCalendar());

                dr[InsuranceInfoData.BirthDate_FIELD] = greorianDateTime;
            }
            #endregion

            //fetch id from comboBox
            int id = int.Parse(cmbInsuranceType.SelectedValue + "");
            dr[InsuranceInfoData.insuranceType_FIELD] = id;
            string insuranceNumber = txtInsuranceNumber.Text.Trim();
            inData.Tables[InsuranceInfoData.insuranceInfo_TABLE].Rows.Add(dr);
            try
            {
                int index;
                if (dataMode == NEW_MODE)
                {
                    index = -1;
                }
                else
                {
                    index = int.Parse(_gridTools.getCurrentRowValue(InsuranceInfoData.id_FIELD).ToString());
                }
                if (isb.checkInsuranceNumberExists(txtInsuranceNumber.Text.Trim(), index))
                {
                    MessageBox.Show("امکان اضافه کردن این رکورد وجود ندارد ، شماره بیمه تکراری است");
                    txtInsuranceNumber.Focus();
                    return;
                }

                if (dataMode.Equals(NEW_MODE))
                {
                    isb.add(inData);
                    InsuranceInfoData iData = isb.getByInsuranceNumer(txtInsuranceNumber.Text.Trim());
                    if (iData.Tables[0].Rows.Count > 0)
                    {
                        addlog(cbxHaveDid.Checked, int.Parse(iData.Tables[0].Rows[0][InsuranceInfoData.id_FIELD].ToString()),
                               iData.Tables[0].Rows[0][InsuranceInfoData.endDate_FIELD].ToString());
                    }
                }
                else if (dataMode.Equals(EDIT_MODE))
                {
                    if (cbxHaveDid.Checked)
                    {
                        checkForLogging(int.Parse(_gridTools.getCurrentRowValue(InsuranceInfoData.id_FIELD).ToString()),
                                        _gridTools.getCurrentRowValue(InsuranceInfoData.endDate_FIELD).ToString());
                    }
                    isb.update(inData);
                }
            }
            catch (Exception ex)
            {
                string s = ex.ToString();
                if (s.IndexOf("duplicate") >= 0)
                {
                    MessageBox.Show("امکان اضافه کردن این رکورد وجود ندارد ، شماره بیمه تکراری است");
                    txtInsuranceNumber.Focus();
                }
                else
                {
                    MessageBox.Show(ex.ToString());
                }
                return;
            }

            btnRefresh_Click(null, null);

            MainForm.MainFormInstance.fillGrid();

            int addedRow = searcInGrid(insuranceNumber);
            if (addedRow == -1)
            {
                dataGridView1.CurrentCell = dataGridView1.Rows[dataGridView1.RowCount - 1].Cells[0];
            }
            else
            {
                dataGridView1.CurrentCell = dataGridView1.Rows[addedRow].Cells[0];
            }
            dataGridView1_SelectionChanged(null, null);

            dataMode = EDIT_MODE;
            fillSearchMap();
            MainForm.MainFormInstance.msDoAgantsJobDirectly();
            //frmMain.msDoAgantsJobDirectly();
        }
Exemple #18
0
        private void btnUpdate_Click(object sender, EventArgs e)
        {
            string check = checkData();

            if (check != null)
            {
                MessageBox.Show(check);
                return;
            }

            InsuranceInfoData inData = new InsuranceInfoData();
            DataRow           dr     = inData.Tables[InsuranceInfoData.insuranceInfo_TABLE].NewRow();

            dr[InsuranceInfoData.id_FIELD]              = _id;
            dr[InsuranceInfoData.name_FIELD]            = txtName.Text.Trim();
            dr[InsuranceInfoData.family_FIELD]          = txtFamily.Text.Trim();
            dr[InsuranceInfoData.phoneNumber_FIELD]     = txtPhoneNumber.Text.Trim();
            dr[InsuranceInfoData.insuranceNumber_FIELD] = txtInsuranceNumber.Text.Trim();

            dr[InsuranceInfoData.haveDid_FIELD]     = cbxHaveDid.Checked;
            dr[InsuranceInfoData.address_FIELD]     = txtAddress.Text.Trim();
            dr[InsuranceInfoData.description_FIELD] = txtDescription.Text.Trim();

            dr[InsuranceInfoData.mobileNumber_FIELD] = txtMobilePhone.Text.Trim();
            dr[InsuranceInfoData.CustomerType_FIELD] = cmbCustomerType.SelectedIndex;

            #region dateValidation
            GregorianCalendar gcal = new GregorianCalendar();
            int d = 12;
            int m = 0;
            int y = 0;
            CheckDate.checkDate(txtBeginDate.Text, ref y, ref m, ref d);
            DateTime persianDateTime  = new DateTime(y, m, d, new PersianCalendar());
            DateTime greorianDateTime =
                new DateTime(gcal.GetYear(persianDateTime),
                             gcal.GetMonth(persianDateTime),
                             gcal.GetDayOfMonth(persianDateTime), new GregorianCalendar());

            dr[InsuranceInfoData.beginDate_FIELD] = greorianDateTime;

            //
            CheckDate.checkDate(txtEndDate.Text, ref y, ref m, ref d);
            persianDateTime  = new DateTime(y, m, d, new PersianCalendar());
            greorianDateTime =
                new DateTime(gcal.GetYear(persianDateTime),
                             gcal.GetMonth(persianDateTime),
                             gcal.GetDayOfMonth(persianDateTime), new GregorianCalendar());

            dr[InsuranceInfoData.endDate_FIELD] = greorianDateTime;
            //

            //Creation Date
            String   todayShamsi;
            String[] dateArr;
            CheckDate.checkDate(txtCreationDate.Text, ref y, ref m, ref d);

            persianDateTime  = new DateTime(y, m, d, new PersianCalendar());
            greorianDateTime =
                new DateTime(gcal.GetYear(persianDateTime),
                             gcal.GetMonth(persianDateTime),
                             gcal.GetDayOfMonth(persianDateTime), new GregorianCalendar());

            dr[InsuranceInfoData.creationDate_FIELD] = greorianDateTime;
            //
            //Last update date
            todayShamsi = RMX_TOOLS.date.DateXFormer.gregorianToPersianString(DateTime.Now);
            dateArr     = todayShamsi.Split('/');

            persianDateTime = new DateTime(int.Parse(dateArr[0]),
                                           int.Parse(dateArr[1]),
                                           int.Parse(dateArr[2]), new PersianCalendar());
            greorianDateTime =
                new DateTime(gcal.GetYear(persianDateTime),
                             gcal.GetMonth(persianDateTime),
                             gcal.GetDayOfMonth(persianDateTime), new GregorianCalendar());

            dr[InsuranceInfoData.lastUpdateDate_FIELD] = greorianDateTime;
            //
            //Birth date
            if (txtBirthDate.Text.Trim() != DateConstants.NULL_Date.Trim())
            {
                CheckDate.checkDate(txtBirthDate.Text, ref y, ref m, ref d);
                persianDateTime  = new DateTime(y, m, d, new PersianCalendar());
                greorianDateTime =
                    new DateTime(gcal.GetYear(persianDateTime),
                                 gcal.GetMonth(persianDateTime),
                                 gcal.GetDayOfMonth(persianDateTime), new GregorianCalendar());

                dr[InsuranceInfoData.BirthDate_FIELD] = greorianDateTime;
            }
            #endregion

            //fetch id from comboBox
            int insuranceTypeId = int.Parse(cmbInsuranceType.SelectedValue + "");
            dr[InsuranceInfoData.insuranceType_FIELD] = insuranceTypeId;
            string insuranceNumber = txtInsuranceNumber.Text.Trim();
            inData.Tables[InsuranceInfoData.insuranceInfo_TABLE].Rows.Add(dr);
            try
            {
                if (insuranceInfoBs.checkInsuranceNumberExists(txtInsuranceNumber.Text.Trim(), _id))
                {
                    MessageBox.Show("امکان اضافه کردن این رکورد وجود ندارد ، شماره بیمه تکراری است");
                    txtInsuranceNumber.Focus();
                    return;
                }

                if (cbxHaveDid.Checked)
                {
                    string endDate = insuranceInfoBs.getEndDateByInsuranceNumer(txtInsuranceNumber.Text.Trim());
                    checkForLogging(_id, endDate);
                }

                if (_id > 0)
                {
                    insuranceInfoBs.update(inData);
                }
                else
                {
                    insuranceInfoBs.add(inData);
                }
                this.Close();
            }
            catch (Exception ex)
            {
                string s = ex.ToString();
                if (s.IndexOf("duplicate") >= 0)
                {
                    MessageBox.Show("امکان اضافه کردن این رکورد وجود ندارد ، شماره بیمه تکراری است");
                    txtInsuranceNumber.Focus();
                }
                else
                {
                    MessageBox.Show(ex.ToString());
                }
                return;
            }


            // MainForm.MainFormInstance.fillGrid();
        }
Exemple #19
0
        private void bntSearchDate_Click(object sender, EventArgs e)
        {
            /**
             * the vaues of comboBox cmbCondition
             * 0 = equal
             * 1 = greater
             * 2 = greater and equal
             * 3 = less than
             * 4 = less and equal
             */
            txtBeginDateFilter_TextChanged(null, null);
            string dateStr = txtBeginDateFilter.Text;

            string condition = "";
            string fld;

            fld = " havedidlog_checkeddate ";

            if (cmbCondition.SelectedIndex < 0)
            {
                MessageBox.Show("شرط تاریخ تعیین نشده است");
                return;
            }

            if (!CheckDate.checkDate(dateStr))
            {
                MessageBox.Show("تاریخ معتبر نیست");
                return;
            }

            DateTime date  = RMX_TOOLS.date.DateXFormer.persianToGreGorian(dateStr);
            string   dateS = date.Year + "/" + date.Month + "/" + date.Day;

            switch (cmbCondition.SelectedIndex)
            {
            case 0:
                condition = fld + " BETWEEN '" + dateS + " " +
                            RMX_TOOLS.date.DateConstants.BEGIN_OF_DAY + "' and '" +
                            dateS + " " + RMX_TOOLS.date.DateConstants.END_OF_DAY + "' ";
                break;

            case 1:
                condition = fld + " > '" + dateS + " " + RMX_TOOLS.date.DateConstants.END_OF_DAY + "' ";
                break;

            case 2:
                condition = fld + " >= '" + dateS + " " + RMX_TOOLS.date.DateConstants.BEGIN_OF_DAY + "' ";
                break;

            case 3:
                condition = fld + " < '" + dateS + " " + RMX_TOOLS.date.DateConstants.BEGIN_OF_DAY + "' ";
                break;

            case 4:
                condition = fld + " <= '" + dateS + " " + RMX_TOOLS.date.DateConstants.END_OF_DAY + "' ";
                break;
            }
            //int v = (cbxHaveDid2.Checked ? 1 : 0);
            // condition += " and " + ViewHaveDidLogData.haveDid_FIELD + "=" + v + " ";
            _condition = condition;
            string cancel = "";// " and(cancel is null or cancel = 0)";

            fillGrid(_condition + cancel);
        }
Exemple #20
0
        private void btnUpdate_Click(object sender, EventArgs e)
        {
            string check = checkData();

            if (check != null)
            {
                MessageBox.Show(check);
                return;
            }
            if (_gridTools.getCurrentRowValue(InsuranceInfoData.id_FIELD) == null)
            {
                return;
            }
            InsuranceInfoBS   isb    = new InsuranceInfoBS();
            InsuranceInfoData inData = new InsuranceInfoData();
            DataRow           dr     = inData.Tables[InsuranceInfoData.insuranceInfo_TABLE].NewRow();

            // if (cmbHaveDid.SelectedIndex == 1)
            //      dr[InsuranceInfoData.haveDid_FIELD] = true;
            // if (cmbHaveDid.SelectedIndex == 2)
            //      dr[InsuranceInfoData.haveDid_FIELD] = false;

            dr[InsuranceInfoData.name_FIELD]            = txtName.Text;
            dr[InsuranceInfoData.family_FIELD]          = txtFamily.Text;
            dr[InsuranceInfoData.phoneNumber_FIELD]     = txtPhoneNumber.Text;
            dr[InsuranceInfoData.insuranceNumber_FIELD] = txtInsuranceNumber.Text;
            dr[InsuranceInfoData.id_FIELD]          = _gridTools.getCurrentRowValue(InsuranceInfoData.id_FIELD);
            dr[InsuranceInfoData.address_FIELD]     = _gridTools.getCurrentRowValue(InsuranceInfoData.address_FIELD);
            dr[InsuranceInfoData.haveDid_FIELD]     = _gridTools.getCurrentRowValue(InsuranceInfoData.haveDid_FIELD);
            dr[InsuranceInfoData.cancel_FIELD]      = _gridTools.getCurrentRowValue(InsuranceInfoData.cancel_FIELD);
            dr[InsuranceInfoData.address_FIELD]     = txtAddress.Text.Trim();
            dr[InsuranceInfoData.description_FIELD] = txtDescription.Text.Trim();
            // Date validation and converion
            #region dateValidation
            GregorianCalendar gcal = new GregorianCalendar();
            int d = 0;
            int m = 0;
            int y = 0;
            CheckDate.checkDate(txtBeginDate.Text, ref y, ref m, ref d);
            DateTime persianDateDime  = new DateTime(y, m, d, new PersianCalendar());
            DateTime greorianDateTime =
                new DateTime(gcal.GetYear(persianDateDime),
                             gcal.GetMonth(persianDateDime),
                             gcal.GetDayOfMonth(persianDateDime), new GregorianCalendar());

            dr[InsuranceInfoData.beginDate_FIELD] = greorianDateTime;

            CheckDate.checkDate(txtEndDate.Text, ref y, ref m, ref d);
            persianDateDime  = new DateTime(y, m, d, new PersianCalendar());
            greorianDateTime =
                new DateTime(gcal.GetYear(persianDateDime),
                             gcal.GetMonth(persianDateDime),
                             gcal.GetDayOfMonth(persianDateDime), new GregorianCalendar());

            dr[InsuranceInfoData.endDate_FIELD] = greorianDateTime;

            #endregion

            //fetch id from comboBox
            int id = int.Parse(cmbInsuranceType.SelectedValue + "");
            dr[InsuranceInfoData.insuranceType_FIELD] = id;

            inData.Tables[InsuranceInfoData.insuranceInfo_TABLE].Rows.Add(dr);
            isb.update(inData);

            string insuranceNumber = txtInsuranceNumber.Text.Trim();

            fillGrid(_condition);

            int addedRow = searcInGrid(insuranceNumber);
            if (addedRow == -1)
            {
                dataGridView1.Rows[dataGridView1.RowCount - 1].Selected = true;
            }

            else
            {
                dataGridView1.Rows[addedRow].Selected = true;
            }

            MainForm.MainFormInstance.fillGrid();
            MessageBox.Show("به روز رسانی انجام شد");
        }
Exemple #21
0
        /// <summary>
        /// Returns true if DepartmentDocumentSearchResponse instances are equal
        /// </summary>
        /// <param name="other">Instance of DepartmentDocumentSearchResponse to be compared</param>
        /// <returns>Boolean</returns>
        public bool Equals(DepartmentDocumentSearchResponse other)
        {
            if (ReferenceEquals(null, other))
            {
                return(false);
            }
            if (ReferenceEquals(this, other))
            {
                return(true);
            }

            return
                ((
                     FirstName == other.FirstName ||
                     FirstName != null &&
                     FirstName.Equals(other.FirstName)
                     ) &&
                 (
                     LastName == other.LastName ||
                     LastName != null &&
                     LastName.Equals(other.LastName)
                 ) &&
                 (
                     CompanyName == other.CompanyName ||
                     CompanyName != null &&
                     CompanyName.Equals(other.CompanyName)
                 ) &&
                 (
                     DepartmentDocumentNumber == other.DepartmentDocumentNumber ||
                     DepartmentDocumentNumber != null &&
                     DepartmentDocumentNumber.Equals(other.DepartmentDocumentNumber)
                 ) &&
                 (
                     CheckNumber == other.CheckNumber ||
                     CheckNumber != null &&
                     CheckNumber.Equals(other.CheckNumber)
                 ) &&
                 (
                     CheckAmount == other.CheckAmount ||
                     CheckAmount != null &&
                     CheckAmount.Equals(other.CheckAmount)
                 ) &&
                 (
                     CheckDate == other.CheckDate ||
                     CheckDate != null &&
                     CheckDate.Equals(other.CheckDate)
                 ) &&
                 (
                     TransmittalNumber == other.TransmittalNumber ||
                     TransmittalNumber != null &&
                     TransmittalNumber.Equals(other.TransmittalNumber)
                 ) &&
                 (
                     TransmittalStatus == other.TransmittalStatus ||
                     TransmittalStatus != null &&
                     TransmittalStatus.Equals(other.TransmittalStatus)
                 ) &&
                 (
                     DepositNumber == other.DepositNumber ||
                     DepositNumber != null &&
                     DepositNumber.Equals(other.DepositNumber)
                 ) &&
                 (
                     CashListing == other.CashListing ||
                     CashListing != null &&
                     CashListing.Equals(other.CashListing)
                 ));
        }
        private void bntSearchDate_Click(object sender, EventArgs e)
        {
            /**
             * the vaues of comboBox cmbCondition
             * 0 = equal
             * 1 = greater
             * 2 = greater and equal
             * 3 = less than
             * 4 = less and equal
             */
            txtBeginDateFilter_TextChanged(null, null);
            string dateStr = txtBeginDateFilter.Text;

            string condition = "";
            string fld;

            fld = ViewInsuranceInfoData.endDate_FIELD;


            if (cmbCondition.SelectedIndex < 0)
            {
                MessageBox.Show("شرط تاریخ تعیین نشده است");
                return;
            }

            if (!CheckDate.checkDate(dateStr))
            {
                MessageBox.Show("تاریخ معتبر نیست");
                return;
            }
            DateTime      date = RMX_TOOLS.date.DateXFormer.persianToGreGorian(dateStr);
            IDataProvider dp   = Config.provider;

            switch (cmbCondition.SelectedIndex)
            {
            case 0:
                if (rBtnHaveDid.Checked)
                {
                    condition = dp.getBetweenDate(fld, date, date, null);
                }
                else if (rBtnOP.Checked)
                {
                    condition = dp.getBetweenDate(fld, date, date, ViewInsuranceInfoData.DAYSBEFOREXP_FIELD);
                }
                break;

            case 1:
                if (rBtnHaveDid.Checked)
                {
                    condition = fld + ">" + dp.getAsSqlDate(date.ToShortDateString(), RMX_TOOLS.date.DateConstants.END_OF_DAY);
                }
                else if (rBtnOP.Checked)
                {
                    condition = fld + ">" + dp.getAsSqlDate(date.ToShortDateString(),
                                                            RMX_TOOLS.date.DateConstants.END_OF_DAY) + " + " + ViewInsuranceInfoData.DAYSBEFOREXP_FIELD;
                }
                break;

            case 2:
                if (rBtnHaveDid.Checked)
                {
                    condition = fld + " >= " + dp.getAsSqlDate(date.ToShortDateString(), RMX_TOOLS.date.DateConstants.BEGIN_OF_DAY);
                }
                else if (rBtnOP.Checked)
                {
                    condition = fld + " >= " + dp.getAsSqlDate(date.ToShortDateString(),
                                                               RMX_TOOLS.date.DateConstants.BEGIN_OF_DAY) + " + " + ViewInsuranceInfoData.DAYSBEFOREXP_FIELD;
                }
                break;

            case 3:
                if (rBtnHaveDid.Checked)
                {
                    condition = fld + " < " + dp.getAsSqlDate(date.ToShortDateString(), RMX_TOOLS.date.DateConstants.BEGIN_OF_DAY);
                }
                else if (rBtnOP.Checked)
                {
                    condition = fld + " < " + dp.getAsSqlDate(date.ToShortDateString(),
                                                              RMX_TOOLS.date.DateConstants.BEGIN_OF_DAY) + " + " + ViewInsuranceInfoData.DAYSBEFOREXP_FIELD;
                }
                break;

            case 4:
                if (rBtnHaveDid.Checked)
                {
                    condition = fld + " < " + dp.getAsSqlDate(date.ToShortDateString(), RMX_TOOLS.date.DateConstants.END_OF_DAY);
                }
                else if (rBtnOP.Checked)
                {
                    condition = fld + " < " + dp.getAsSqlDate(date.ToShortDateString(),
                                                              RMX_TOOLS.date.DateConstants.END_OF_DAY) + " + " + ViewInsuranceInfoData.DAYSBEFOREXP_FIELD;
                }
                break;
            }
            //  int v = (cbxHaveDid2.Checked ? 1 : 0);
            //  condition += " and " + ViewInsuranceInfoData.haveDid_FIELD + "=" + v + " ";
            _condition = condition;
            string cancel = "";// " and(cancel is null or cancel = 0)";

            fillGrid(_condition + cancel);
        }