Example #1
0
        private void fillGrid()
        {
            if (selectedIds.Count == 0)
            {
                return;
            }
            InsuranceInfoBS   bs   = new InsuranceInfoBS();
            InsuranceInfoData data = bs.getByIds(selectedIds);

            DataRowCollection rows = data.Tables[0].Rows;

            for (int i = 0; i < rows.Count; i++)
            {
                long id = (long)rows[i][InsuranceInfoData.id_FIELD];

                Object[] row = new object[8];
                row[0] = i + 1;
                row[1] = "";
                row[2] = "";
                row[3] = rows[i][InsuranceInfoData.mobileNumber_FIELD];
                row[4] = rows[i][InsuranceInfoData.name_FIELD];
                row[5] = rows[i][InsuranceInfoData.family_FIELD];
                row[6] = rows[i][InsuranceInfoData.insuranceNumber_FIELD];
                row[7] = rows[i][InsuranceInfoData.id_FIELD] = id;
                dataGridView1.Rows.Add(row);
            }
        }
Example #2
0
        private void initForm()
        {
            isDeleted = false;
            if (_id > 0)
            {
                InsuranceInfoData data = insuranceInfoBs.getById(_id);
                txtName.Text = data.Tables[InsuranceInfoData.insuranceInfo_TABLE].Rows[0][InsuranceInfoData.name_FIELD].ToString();
                cmbCustomerType.SelectedIndex =
                    (int)data.Tables[InsuranceInfoData.insuranceInfo_TABLE].Rows[0][InsuranceInfoData.CustomerType_FIELD];
                txtFamily.Text      = data.Tables[InsuranceInfoData.insuranceInfo_TABLE].Rows[0][InsuranceInfoData.family_FIELD].ToString();
                txtPhoneNumber.Text = data.Tables[InsuranceInfoData.insuranceInfo_TABLE].Rows[0][InsuranceInfoData.phoneNumber_FIELD].ToString();
                txtMobilePhone.Text = data.Tables[InsuranceInfoData.insuranceInfo_TABLE].Rows[0][InsuranceInfoData.mobileNumber_FIELD].ToString();
                txtBirthDate.Text   = toShamsiString(data, InsuranceInfoData.BirthDate_FIELD);
                txtAddress.Text     = data.Tables[InsuranceInfoData.insuranceInfo_TABLE].Rows[0][InsuranceInfoData.address_FIELD].ToString();

                selectComboItemForInsuraceType(int.Parse(
                                                   data.Tables[InsuranceInfoData.insuranceInfo_TABLE].Rows[0][InsuranceInfoData.insuranceType_FIELD].ToString()));
                txtInsuranceNumber.Text = data.Tables[InsuranceInfoData.insuranceInfo_TABLE].Rows[0][InsuranceInfoData.insuranceNumber_FIELD].ToString();

                txtBeginDate.Text = toShamsiString(data, InsuranceInfoData.beginDate_FIELD);
                txtEndDate.Text   = toShamsiString(data, InsuranceInfoData.endDate_FIELD);

                txtLastUpdateDate.Text = toShamsiString(data, InsuranceInfoData.creationDate_FIELD);
                txtCreationDate.Text   = toShamsiString(data, InsuranceInfoData.lastUpdateDate_FIELD);

                txtDescription.Text = data.Tables[InsuranceInfoData.insuranceInfo_TABLE].Rows[0][InsuranceInfoData.description_FIELD].ToString();
            }
            else
            {
                linkAttachment.Enabled = false;
                txtCreationDate.Text   = getTodayShamsi();
                txtLastUpdateDate.Text = getTodayShamsi();
            }
        }
Example #3
0
        public string getEndDateByInsuranceNumer(string insNum)
        {
            InsuranceInfoData data    = _insuranceInfoDAL.getByInsuranceNumer(insNum);
            string            enddate =
                data.Tables[InsuranceInfoData.insuranceInfo_TABLE].Rows[0][InsuranceInfoData.endDate_FIELD].ToString();

            return(enddate);
        }
Example #4
0
        public InsuranceInfoData load(string condition)
        {
            InsuranceInfoData ds = new InsuranceInfoData();

            dp.loadToDataSet(InsuranceInfoData.insuranceInfo_TABLE, ds, "(cancel is null or cancel=0)" + condition);
            fillRadif(ds);
            return(ds);
        }
Example #5
0
        private String toShamsiString(InsuranceInfoData data, string fieldName)
        {
            Object obj = data.Tables[InsuranceInfoData.insuranceInfo_TABLE].Rows[0][fieldName];

            if (obj != null && obj.ToString().Length > 0)
            {
                return(RMX_TOOLS.date.DateXFormer.gregorianToPersianString((DateTime)obj));
            }
            return("");
        }
Example #6
0
        private void checkForLogging(int insuranceInfoId, string endDateStr)
        {
            InsuranceInfoBS   insBS   = new InsuranceInfoBS();
            InsuranceInfoData insData = insBS.getById(insuranceInfoId);

            if (insData.Tables[0].Rows.Count > 0)
            {
                Boolean haveDid = Boolean.Parse(insData.Tables[0].Rows[0][InsuranceInfoData.haveDid_FIELD].ToString());
                if (haveDid == false)
                {
                    addlog(true, insuranceInfoId, endDateStr);
                }
            }
        }
Example #7
0
        public Boolean checkInsuranceNumberExists(string insNumber, int index)
        {
            InsuranceInfoData dataSet = new InsuranceInfoData();
            //string query = "SELECT * FROM INSURACEINFO WHERE INSURANCENUMBER = '" + insNumber + "'";
            string cond = "INSURANCENUMBER = '" + insNumber + "'";

            if (index >= 0)
            {
                cond += "and id <>" + index;
            }
            dp.loadToDataSet("INSURANCEINFO", dataSet, cond);
            if (dataSet.Tables[0].Rows.Count <= 0)
            {
                return(false);
            }
            else
            {
                return(true);
            }
        }
Example #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();
        }
Example #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();
        }
Example #10
0
 public int update(InsuranceInfoData dataSet)
 {
     return(_insuranceInfoDAL.update(dataSet));
 }
Example #11
0
 public int add(InsuranceInfoData dataSet)
 {
     return(_insuranceInfoDAL.add(dataSet));
 }
Example #12
0
 public int update(InsuranceInfoData dataSet)
 {
     return(dp.update(dataSet, InsuranceInfoData.insuranceInfo_TABLE));
 }
Example #13
0
 public int add(InsuranceInfoData dataSet)
 {
     return(dp.add(dataSet, InsuranceInfoData.insuranceInfo_TABLE));
 }
Example #14
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("به روز رسانی انجام شد");
        }