Esempio n. 1
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);
        }
Esempio n. 2
0
        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);
        }
Esempio n. 3
0
        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);
        }
Esempio n. 4
0
        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);
        }
Esempio n. 5
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);
        }
Esempio n. 6
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);
        }
Esempio n. 7
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);
        }
Esempio n. 8
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();
        }
Esempio n. 9
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();
        }
Esempio n. 10
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 = 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);
        }
Esempio n. 11
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("به روز رسانی انجام شد");
        }
Esempio n. 12
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);
        }