コード例 #1
0
        public ChequeEntity get(string cond)
        {
            ChequeEntity entity = new ChequeEntity();

            provider.loadToDataSet(entity, cond);
            return(entity);
        }
コード例 #2
0
ファイル: ChequeBL.cs プロジェクト: sohbati/Automation
        public static void fillComboBox(ComboBox cmb, int defaultItem)
        {
            cmb.Items.Clear();
            ChequeBL bl = new ChequeBL();

            ChequeEntity entity     = bl.get();
            var          dataSource = new List <ComboBoxItem>();

            BasicInfoUtil.AddUnKnown(dataSource);

            for (int i = 0; i < entity.Tables[entity.FilledTableName].Rows.Count; i++)
            {
                string id   = entity.Tables[entity.FilledTableName].Rows[i][ChequeEntity.FIELD_ID].ToString();
                string desc = entity.Tables[entity.FilledTableName].Rows[i][ChequeEntity.FIELD_BANK_ID].ToString();

                dataSource.Add(new ComboBoxItem(desc, id, ""));
            }
            cmb.DataSource    = dataSource;
            cmb.DisplayMember = "Text";
            cmb.ValueMember   = "Value";

            for (int i = 0; i < cmb.Items.Count; i++)
            {
                if (((ComboBoxItem)cmb.Items[i]).Value.Equals(defaultItem.ToString()))
                {
                    cmb.SelectedIndex = i;
                    break;
                }
            }
        }
コード例 #3
0
        public void loadForm()
        {
            lblTextMessage.Text = "";


            _userTreeIds = getSameUserIdsLikeThisNode(_userTreeId);

            LetterEntity letterentity1 = _letterBl.getByUserTreeIds(_userTreeIds);
            ChequeEntity chequeEntity2 = _chequeBL.getByUserTreeIds(_userTreeIds);

            LetterEntity letterentity3 = _letterBl.getByUserTreeId(_userTreeId);
            ChequeEntity chequeEntity4 = _chequeBL.getByUserTreeId(_userTreeId);

            if (letterentity1.Tables[letterentity1.FilledTableName].Rows.Count <= 0 &&
                chequeEntity2.Tables[chequeEntity2.FilledTableName].Rows.Count <= 0)
            {
                cmbReferenceUserId.Enabled = false;
                btnReffferLetter.Enabled   = false;

                lblTextMessage.Text = "این کاربر نامه ای   یا چکی در اختیار ندارد";
            }
            else
            {
                cmbReferenceUserId.Enabled = true;
                btnReffferLetter.Enabled   = true;
                lblTextMessage.Text        = "ارجاعات";
                lbl1.Text = letterentity1.RowCount().ToString();
                lbl2.Text = chequeEntity2.RowCount().ToString();
                lbl3.Text = letterentity3.RowCount().ToString();
                lbl4.Text = chequeEntity4.RowCount().ToString();

                fillUserRefferenceCombo(-1);
            }
        }
コード例 #4
0
        public int delete(int id)
        {
            AbstractCommonData entity   = new ChequeEntity();
            string             delQuery = "DELETE FROM " + entity.TableName + " where " + entity.IndexFieldName + "=" + provider.getSQLString(id);

            return(provider.delete(delQuery));
        }
コード例 #5
0
        public ChequeEntity get(string cond, bool isArchived, int userid)
        {
            string archive = "";

            if (!isArchived)
            {
                archive = " (ARCHIVE is null OR ARCHIVE=0) ";
            }
            else
            {
                archive = " ARCHIVE=1 ";
            }

            ChequeEntity entity = new ChequeEntity();

            if (cond.Length > 0)
            {
                cond += " AND ";
            }
            cond += archive;

            cond += " AND (" + ChequeEntity.VIEW_FIELD_REFERENCED_USER_ID + "=" + provider.getSQLString(userid) +
                    " AND GETDATE() - CAST('1900-01-04' AS DATETIME) >" + ChequeEntity.FIELD_REFFER_DATE + ")";
            provider.loadToDataSet(entity, cond);
            return(entity);
        }
コード例 #6
0
        private void FillGrids()
        {
            if (UsersBS.loginedUser != null && UsersBS.loginedUser.get(UsersEntity.FIELD_ID) != null)
            {
                int userid = int.Parse(UsersBS.loginedUser.get(UsersEntity.FIELD_ID).ToString());

                LetterEntity entityRecieve = _letterBL.get(LetterBL.LETTER_TYPE_RECIEVE, false, userid, true);
                LetterEntity entitySend    = _letterBL.get(LetterBL.LETTER_TYPE_SEND, false, userid, true);

                ChequeEntity entityCheque = _chequeBL.get("(" + ChequeEntity.FIELD_PRICE + "<>" + ChequeEntity.VIEW_FIELD_REMAINED +
                                                          " OR " + ChequeEntity.VIEW_FIELD_REMAINED + " IS NULL)", false, userid);

                System.Collections.Hashtable hash = new Hashtable();
                hash.Add("colorField", "COLOR");

                _gridTools.bindDataToGrid(gridRecieveds, entityRecieve, new GridTools.changingRow(_gridTools.changeColor), hash);

                System.Collections.Hashtable hash2 = new Hashtable();
                hash2.Add("colorField", "COLOR_1");

                _gridTools.bindDataToGrid(gridSends, entitySend, new GridTools.changingRow(_gridTools.changeColor), hash2);

                //checque
                System.Collections.Hashtable hash3 = new Hashtable();
                hash3.Add("colorField", "COLOR_2");

                _gridTools.bindDataToGrid(chequeGridView, entityCheque, new GridTools.changingRow(_gridTools.changeColor), hash3);

                fastActionCheckBank_Tick(null, null);
            }
        }
コード例 #7
0
        public ChequeEntity getRefferedToUser(int userId)
        {
            ChequeEntity entity = new ChequeEntity();
            string       cond   = ChequeEntity.VIEW_FIELD_REFERENCED_USER_ID + "=" + provider.getSQLString(userId);

            return(get(cond));
        }
コード例 #8
0
ファイル: DeleteUserForm.cs プロジェクト: sohbati/Automation
        public void loadForm()
        {
            lblTextMessage.Text = "";


            ChequeEntity chequeEntity = _chequeBL.getByUserTreeId(_userTreeId);
            LetterEntity letterentity = _letterBl.getByUserTreeId(_userTreeId);

            if (letterentity.Tables[letterentity.FilledTableName].Rows.Count <= 0 &&
                chequeEntity.Tables[chequeEntity.FilledTableName].Rows.Count <= 0)
            {
                cmbReferenceUserId.Enabled = false;
                btnReffferLetter.Enabled   = false;
                btnDeleteUser.Enabled      = true;
                lbl3.Text           = "0";
                lbl4.Text           = "0";
                lblTextMessage.Text = "این کاربر نامه ای   و چکی در اختیار ندارد ، می توان این کاربر را حدف نمود";
            }
            else
            {
                btnDeleteUser.Enabled      = false;
                cmbReferenceUserId.Enabled = true;
                btnReffferLetter.Enabled   = true;
                lblTextMessage.Text        = "ارجاعات";
                lbl3.Text = letterentity.RowCount().ToString();
                lbl4.Text = chequeEntity.RowCount().ToString();

                fillUserRefferenceCombo(-1);
            }
        }
コード例 #9
0
ファイル: UserForm.cs プロジェクト: sohbati/Automation
        private int getCheques(int userId)
        {
            ChequeBL     bl = new ChequeBL();
            ChequeEntity e  = bl.getRefferedToUser(userId);
            int          i  = e.Tables[e.FilledTableName].Rows.Count;

            return(i);
        }
コード例 #10
0
        public ChequeEntity get(int id)
        {
            ChequeEntity entity = new ChequeEntity();
            string       cond   = ChequeEntity.FIELD_ID + "=" + provider.getSQLString(id);

            provider.loadToDataSet(entity, cond);
            return(entity);
        }
コード例 #11
0
        public ChequeEntity get()
        {
            ChequeEntity entity = new ChequeEntity();

            //string cond = ChequeEntity.FIELD_LETTER_TYPE + "=" + provider.getSQLString(letterType);
            provider.loadToDataSet(entity);
            return(entity);
        }
コード例 #12
0
        public ChequeEntity getByUserTreeId(int userTreeId)
        {
            ChequeEntity entity = new ChequeEntity();
            string       cond   = ChequeEntity.FIELD_USER_TREE_ID + "=" + provider.getSQLString(userTreeId) +
                                  "AND  (" + ChequeEntity.FIELD_ARCHIVE + "= 0 or " + ChequeEntity.FIELD_ARCHIVE + " is null)";

            provider.loadToDataSet(entity, cond);
            return(entity);
        }
コード例 #13
0
        public int updateRefferenceUser(int chequeId, int userTreeId, int referFromUserId)
        {
            AbstractCommonData entity = new ChequeEntity();
            string             sql    = "UPDATE " + entity.TableName + " SET " + ChequeEntity.FIELD_USER_TREE_ID + "=" + provider.getSQLString(userTreeId) +
                                        " , " + ChequeEntity.FIELD_REFER_FROM_USER_ID + "=" + provider.getSQLString(referFromUserId) +
                                        " WHERE " + entity.IndexFieldName + "=" + provider.getSQLString(chequeId);

            return(provider.executeNonQuery(sql));
        }
コード例 #14
0
        public ChequeEntity getByUserTreeIds(string userTreeIds)
        {
            ChequeEntity entity = new ChequeEntity();
            string       cond   = ChequeEntity.FIELD_USER_TREE_ID + " in(" + userTreeIds + ")" +
                                  "AND  (" + ChequeEntity.FIELD_ARCHIVE + "= 0 or " + ChequeEntity.FIELD_ARCHIVE + " is null)";


            provider.loadToDataSet(entity, cond);
            return(entity);
        }
コード例 #15
0
        public ActionResult Create(ChequeEntity cheque)
        {
            if (ModelState.IsValid)
            {
                // Serialize object to a string and store in TempData
                var serializedObject = JsonConvert.SerializeObject(cheque);
                TempData["cheque"] = serializedObject;

                return(RedirectToAction("Show", "cheque"));
            }

            return(View());
        }
コード例 #16
0
        public ChequeEntity getGridChequeWithoutAnswer(int userid)
        {
            String CHEQUE_WHITHOUT_ANS = " SELECT    * FROM         dbo.VIEW_CHEQUE AS R" +
                                         "   WHERE   (ARCHIVE IS NULL OR ARCHIVE = 0)AND (R.REFFERDATE < GETDATE() - CAST('1900-01-04' AS DATETIME)) AND " +
                                         "    (NOT EXISTS " +
                                         " (SELECT     ID, CHEQUEID, RECIEPTBILLNUMBER, ISSUEDATE, PRICE, DESCRIPTION, REGISTERDATE, REGISTRANTUSER " +
                                         " FROM         dbo.CHEQUEREPLY AS CHEQUEREPLY_1 " +
                                         " WHERE     (CHEQUEID = R.ID))) " +

                                         "     " +
                                         "                  AND USERTREEID IN(SELECT USERTREE.ID FROM USERTREE WHERE USERID =@userid@)";

            ChequeEntity entity = new ChequeEntity();

            RMX_TOOLS.data.Config.provider.executeSelect(CHEQUE_WHITHOUT_ANS.Replace(_userLable, userid + ""), entity, entity.Tables[1].TableName);
            return(entity);
        }
コード例 #17
0
        public ChequeEntity getGridChequeHasRemainder(int userid)
        {
            String CHEQUE_HAS_REMAINDER = " SELECT * FROM         (SELECT     *,  ID AS CHEQUEID " +
                                          "    FROM         dbo.VIEW_CHEQUE) AS R_1 " +
                                          "    WHERE  (ARCHIVE IS NULL OR ARCHIVE = 0) AND (R_1.REFFERDATE < GETDATE() - CAST('1900-01-04' AS DATETIME)) AND (PRICE<>REMAINED OR REMAINED IS NULL) AND " +
                                          "         EXISTS " +
                                          "              (SELECT     ID, CHEQUEID, RECIEPTBILLNUMBER, ISSUEDATE, PRICE, DESCRIPTION, " +
                                          "              REGISTERDATE, REGISTRANTUSER " +
                                          "                 FROM         dbo.CHEQUEREPLY AS CHEQUEREPLY_2 " +
                                          "                 WHERE     (CHEQUEID = R_1.CHEQUEID)) " +
                                          "     " +
                                          "                  AND USERTREEID IN(SELECT USERTREE.ID FROM USERTREE WHERE USERID =@userid@)";

            ChequeEntity entity = new ChequeEntity();

            RMX_TOOLS.data.Config.provider.executeSelect(CHEQUE_HAS_REMAINDER.Replace(_userLable, userid + ""), entity, entity.Tables[1].TableName);
            return(entity);
        }
コード例 #18
0
        private void fillGrid(string cond)
        {
            //entity = _chequeBL.get(cond);
            if (rbDisplayAll.Checked)
            {
                _entity = _chequeBL.get(cond);
            }
            else if (rbDisplayArchived.Checked)
            {
                _entity = _chequeBL.get(cond, true);
            }
            else
            {
                _entity = _chequeBL.get(cond, false);
            }

            System.Collections.Hashtable hash = new Hashtable();
            hash.Add("colorField", "COLOR");
            _gridTools.bindDataToGrid(dataGridView1, _entity, new GridTools.changingRow(_gridTools.changeColor), hash);
        }
コード例 #19
0
        private void btnReferToMasterUser_Click(object sender, EventArgs e)
        {
            if (_id < 0)
            {
                return;
            }
            ChequeEntity entity = _chequeBL.get(_id);

            if (entity != null && entity.Tables[entity.FilledTableName].Rows.Count > 0)
            {
                //نودی از درخت که نامه در دست وی است
                //ابتدا بررسی می کنیم که آیا کاربر وارد شده همان شخصی است که این نامه در دست وی است ،
                // اگر نبود یک سوال پرسیده خواهد شد.
                int userTreeId = -1;
                if (entity.get(ChequeEntity.FIELD_USER_TREE_ID).ToString().Length > 0)
                {
                    userTreeId = int.Parse(entity.get(ChequeEntity.FIELD_USER_TREE_ID).ToString());
                }

                bool iss = checkIsLetterUserEqualLogginedUser(userTreeId);
                if (!iss)
                {
                    DialogResult re = MessageBox.Show("این چک در اختیار شما نمی باشد! آیا مایلید که آن را  به شخص دیگری ارجاع نمایید ؟ ", "", MessageBoxButtons.YesNo);
                    if (re.Equals(DialogResult.No))
                    {
                        return;
                    }
                }

                RefferToForm form = new RefferToForm(txtRefferDate.Enabled);
                form.UserTreeId = userTreeId;
                form.ChequeId   = _id;
                form.LoadForm();
                form.ShowDialog();
                if (form.IsRefferDone)
                {
                    this.DataChanged1 = true;
                    this.Close();
                }
            }
        }
コード例 #20
0
        public ChequeEntity get(string cond, bool isArchived)
        {
            string archive = "";

            if (!isArchived)
            {
                archive = " (ARCHIVE is null OR ARCHIVE=0) ";
            }
            else
            {
                archive = " ARCHIVE=1 ";
            }

            ChequeEntity entity = new ChequeEntity();

            if (cond.Length > 0)
            {
                cond += " AND ";
            }
            cond += archive;

            provider.loadToDataSet(entity, cond);
            return(entity);
        }
コード例 #21
0
ファイル: ChequeBL.cs プロジェクト: sohbati/Automation
 public int update(ChequeEntity entity)
 {
     return(((ChequeDA)_abstractDA).update(entity));
 }
コード例 #22
0
 public int update(ChequeEntity entity)
 {
     return(provider.update(entity));
 }
コード例 #23
0
        private void btnReffferLetter_Click(object sender, EventArgs e)
        {
            LetterBL letterBL = new LetterBL();
            ChequeBL chequeBL = new ChequeBL();

            IsRefferDone = false;
            int assignedUserId = 0;

            if (LetterId > 0)
            {
                LetterEntity letterEntity       = letterBL.getByLetterId(LetterId);
                int          assignedUserTreeId = int.Parse(letterEntity.get(LetterEntity.FIELD_USER_TREE_ID).ToString());
                assignedUserId = _userTreeBL.getUserIdByTreeId(assignedUserTreeId);
                bool b = FormChecker.CheckDate(txtRefferDate, lblRefferDate);
                if (!b)
                {
                    return;
                }
            }

            if (ChequeId > 0)
            {
                ChequeEntity chequeEntity       = chequeBL.get(ChequeId);
                int          assignedUserTreeId = int.Parse(chequeEntity.get(ChequeEntity.FIELD_USER_TREE_ID).ToString());
                assignedUserId = _userTreeBL.getUserIdByTreeId(assignedUserTreeId);
            }
            if (lstUserList.Items.Count <= 0 || lstUserList.SelectedIndex < 0)
            {
                MessageBox.Show("لطفا کاربری را انتخاب نمایید !");
                return;
            }
            ComboBoxItem item       = (ComboBoxItem)lstUserList.Items[lstUserList.SelectedIndex];
            int          userTreeId = int.Parse(item.Value);


            int assigntoNewUserID = _userTreeBL.getUserIdByTreeId(userTreeId);

            if (assignedUserId == assigntoNewUserID)
            {
                MessageBox.Show("آیتم مورد نظر در حال حاضر در اختیار کاربر انتخاب شده می باشد. ");
                return;
            }

            DialogResult re = MessageBox.Show("آیا از انجام عمل ارجاع مطمئن هستید ؟  ", "", MessageBoxButtons.YesNo);

            if (re.Equals(DialogResult.No))
            {
                return;
            }


            if (_letterId >= 0)
            {
                letterBL.updateRefferenceUser(_letterId, userTreeId);

                letterBL.updateRefferenceDate(RMX_TOOLS.date.DateXFormer.persianToGreGorian(txtRefferDate.Text), LetterId);

                lblMsg.Text = "ارجاع انجام گردید!";
            }
            else if (_chequeId >= 0)
            {
                chequeBL.updateRefferenceUser(_chequeId, userTreeId);
                lblMsg.Text = "ارجاع انجام گردید!";
            }
            IsRefferDone = true;

            // this.Close();
        }
コード例 #24
0
ファイル: ChequeBL.cs プロジェクト: sohbati/Automation
 public int add(ChequeEntity entity)
 {
     return(((ChequeDA)_abstractDA).add(entity));
 }
コード例 #25
0
        public void initForm()
        {
            cmbPayType.Items.Clear();
            ComboBoxItem item = new ComboBoxItem("چک", "0");

            cmbPayType.Items.Add(item);
            item = new ComboBoxItem("نقد", "1");
            cmbPayType.Items.Add(item);

            int           bankid    = 0;
            int           companyId = 0;
            DateConverter converter = new DateConverter();

            if (_id > 0)
            {
                ChequeEntity entity = _chequeBL.get(_id);

                if (entity.get(ChequeEntity.FIELD_PAY_TYPE).ToString().Length > 0)
                {
                    if (((bool)entity.get(ChequeEntity.FIELD_PAY_TYPE)) == true)
                    {
                        cmbPayType.SelectedIndex = 1;
                    }
                    else
                    {
                        cmbPayType.SelectedIndex = 0;
                    }
                }
                else
                {
                    cmbPayType.SelectedIndex = -1;
                    lblCbArchive.Visible     = false;
                    cbArchive.Visible        = false;
                }
                if (entity.get(ChequeEntity.FIELD_USER_TREE_ID).ToString().Length > 0)
                {
                    _userTreeId = int.Parse(entity.get(ChequeEntity.FIELD_USER_TREE_ID).ToString());
                }

                txtChequeNumber.Text      = entity.get(ChequeEntity.FIELD_CHEQUE_NUMBER).ToString();
                txtMaturityDate.Text      = converter.valueToString(entity.get(ChequeEntity.FIELD_MATURITY_DATE));
                txtEntryDate.Text         = converter.valueToString(entity.get(ChequeEntity.FIELD_ENTRY_DATE));
                txtRefferDate.Text        = converter.valueToString(entity.get(ChequeEntity.FIELD_REFFER_DATE));
                txtPrice.Text             = entity.get(ChequeEntity.FIELD_PRICE).ToString();
                txtAccountNumber.Text     = entity.get(ChequeEntity.FIELD_ACCOUNT_NUMBER).ToString();
                txtInsuranceNumber.Text   = entity.get(ChequeEntity.FIELD_INSURANCE_NUMBER).ToString();
                txtAccountHolderName.Text = entity.get(ChequeEntity.FIELD_ACCOUNT_HOLDER_NAME).ToString();
                //txtDescription.Text = entity.get(ChequeEntity.FIELD_DESCRIPTION).ToString();
                txtRegistrantUser.Text = UsersBS.loginedUser.ToString();
                if (entity.get(ChequeEntity.FIELD_BANK_ID).ToString().Length > 0)
                {
                    bankid = int.Parse(entity.get(ChequeEntity.FIELD_BANK_ID).ToString());
                }

                txtCompany.Tag = 0;
                if (entity.get(ChequeEntity.FIELD_COMPANY_ID).ToString().Length > 0)
                {
                    txtCompany.Tag  = (int)entity.get(ChequeEntity.FIELD_COMPANY_ID);
                    txtCompany.Text = CompanyBL.getCompanyName((int)txtCompany.Tag);
                }

                cbArchive.Checked = (Boolean)("".Equals(entity.get(ChequeEntity.FIELD_ARCHIVE).ToString()) ? false : entity.get(ChequeEntity.FIELD_ARCHIVE));

                if (entity.get(ChequeEntity.FIELD_INSURANCE_COMPANY).ToString().Length > 0)
                {
                    companyId = int.Parse(entity.get(ChequeEntity.FIELD_INSURANCE_COMPANY).ToString());
                }

                UsersBS usersBs = new UsersBS();
                string  s       = "";
                int     id      = -1;
                if (entity.get(ChequeEntity.FIELD_REGISTRANT_USER).ToString().Length > 0)
                {
                    UsersEntity ue = usersBs.get(int.Parse(entity.get(ChequeEntity.FIELD_REGISTRANT_USER).ToString()));
                    if (ue.Tables[ue.FilledTableName].Rows.Count <= 0)
                    {
                        s  = UsersBS.loginedUser.ToString();
                        id = int.Parse(UsersBS.loginedUser.get(UsersEntity.FIELD_ID).ToString());
                    }
                    else
                    {
                        s  = ue.ToString();
                        id = int.Parse(ue.get(UsersEntity.FIELD_ID).ToString());
                    }
                }
                else
                {
                    s  = UsersBS.loginedUser.ToString();
                    id = int.Parse(UsersBS.loginedUser.get(UsersEntity.FIELD_ID).ToString());
                }
                txtRegistrantUser.Text = s;
                txtRegistrantUser.Tag  = id;

                if (entity.get(ChequeEntity.FIELD_REGISTER_DATE) != null &&
                    entity.get(ChequeEntity.FIELD_REGISTER_DATE).ToString().Length > 0)
                {
                    txtRegisterDate.Text = converter.valueToString(entity.get(ChequeEntity.FIELD_REGISTER_DATE));
                }
                else
                {
                    txtRegisterDate.Text = converter.valueToString(DateTime.Now);
                }

                cmbReferenceUserId.Visible = false;
                lblReferenceUserId.Visible = false;
            }
            else
            {
                //lblChqueReply.Visible = false;
                tblReply.Visible       = false;
                txtRegistrantUser.Tag  = UsersBS.loginedUser.get(UsersEntity.FIELD_ID);
                txtRegistrantUser.Text = UsersBS.loginedUser.ToString();

                txtRegisterDate.Text = converter.valueToString(DateTime.Now);

                cmbReferenceUserId.Visible = true;
                lblReferenceUserId.Visible = true;
                fillUserRefferenceCombo(-1);
                txtCompany.Tag = 0;
            }

            BasicInfoUtil.fillComboBox(cmbInsuranceCompany, "InsuranceCompany", companyId);
            BasicInfoUtil.fillComboBox(cmbBankId, "Bank", bankid);
            initList();

            if (readOnly == true)
            {
                btnSave.Enabled = false;
                btnReferToMasterUser.Enabled = false;
            }

            setPermision();
            if (_id < 0)
            {
                linkAttachment.Visible = false;
            }
        }
コード例 #26
0
 public int add(ChequeEntity entity)
 {
     return(provider.add(entity));
 }
コード例 #27
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            if (!BeforSave())
            {
                return;
            }

            DateConverter dateconverter = new DateConverter();

            ChequeEntity entity = new ChequeEntity();
            DataRow      dr     = entity.Tables[entity.TableName].NewRow();

            if (_id > 0)
            {
                dr[ChequeEntity.FIELD_ID] = _id;
            }

            dr[ChequeEntity.FIELD_PAY_TYPE]      = cmbPayType.SelectedIndex == 0 ? false : true;
            dr[ChequeEntity.FIELD_CHEQUE_NUMBER] = txtChequeNumber.Text;
            dr[ChequeEntity.FIELD_MATURITY_DATE] = dateconverter.stringToValue(txtMaturityDate.Text);
            dr[ChequeEntity.FIELD_ENTRY_DATE]    = dateconverter.stringToValue(txtEntryDate.Text);
            dr[ChequeEntity.FIELD_PRICE]         = txtPrice.Text;
            if (cmbBankId.SelectedIndex == 0)
            {
                dr[ChequeEntity.FIELD_BANK_ID] = 0;
            }
            else
            {
                dr[ChequeEntity.FIELD_BANK_ID] = ((ComboBoxItem)cmbBankId.Items[cmbBankId.SelectedIndex]).Value;
            }

            dr[ChequeEntity.FIELD_ARCHIVE] = cbArchive.Checked;

            dr[ChequeEntity.FIELD_ACCOUNT_NUMBER]      = txtAccountNumber.Text;
            dr[ChequeEntity.FIELD_INSURANCE_NUMBER]    = txtInsuranceNumber.Text;
            dr[ChequeEntity.FIELD_ACCOUNT_HOLDER_NAME] = txtAccountHolderName.Text;
            //dr[ChequeEntity.FIELD_DESCRIPTION] = txtDescription.Text;

            dr[ChequeEntity.FIELD_INSURANCE_COMPANY] = ((ComboBoxItem)cmbInsuranceCompany.Items[cmbInsuranceCompany.SelectedIndex]).Value;

            dr[ChequeEntity.FIELD_REGISTER_DATE]   = dateconverter.stringToValue(txtRegisterDate.Text);
            dr[ChequeEntity.FIELD_REGISTRANT_USER] = txtRegistrantUser.Tag;
            dr[ChequeEntity.FIELD_COMPANY_ID]      = txtCompany.Tag;

            if (String.Join("", txtRefferDate.Text.Split('/')).Trim().Length == 0)
            {
                dr[ChequeEntity.FIELD_REFFER_DATE] = dateconverter.stringToValue(txtRegisterDate.Text);
            }
            else
            {
                dr[ChequeEntity.FIELD_REFFER_DATE] = dateconverter.stringToValue(txtRefferDate.Text);
            }

            if (_id < 0)
            {
                int treeId         = int.Parse(((ComboBoxItem)cmbReferenceUserId.Items[cmbReferenceUserId.SelectedIndex]).Value);
                int loggindeUserId = int.Parse(UsersBS.loginedUser.get(UsersEntity.FIELD_ID).ToString());

                dr[ChequeEntity.FIELD_USER_TREE_ID]       = treeId;
                dr[ChequeEntity.FIELD_REFER_FROM_USER_ID] = loggindeUserId;
                dr[ChequeEntity.FIELD_REGISTRANT_USER]    = loggindeUserId;

                entity.Tables[entity.TableName].Rows.Add(dr);

                _id         = _chequeBL.add(entity);
                lblMsg.Text = "دخیره شده ";
                //int treeId = int.Parse(((ComboBoxItem)cmbReferenceUserId.Items[cmbReferenceUserId.SelectedIndex]).Value);
                //int updateds = _chequeBL.updateRefferenceUser(_id, treeId);

                cmbReferenceUserId.Visible = false;
                lblReferenceUserId.Visible = false;

                checkColorOFCheque();
                tblReply.Visible = true;
            }
            else
            {
                dr[ChequeEntity.FIELD_ID] = _id;

                dr[ChequeEntity.FIELD_USER_TREE_ID] = _userTreeId;

                entity.Tables[entity.TableName].Rows.Add(dr);

                _chequeBL.update(entity);
                checkColorOFCheque();
                lblMsg.Text = "به روز رسانی گردید.";
                this.Close();
            }
            DataChanged = true;
        }