private void createTree(UserTreeEntity entity, TreeNode node) { UsersEntity userEntity = null; for (int i = 0; i < entity.Tables[entity.FilledTableName].Rows.Count; i++) { int childUserId = int.Parse(entity.get(i, UserTreeEntity.FIELD_USER_ID).ToString()); int parentId = int.Parse(entity.get(i, UserTreeEntity.FIELD_ID).ToString()); userEntity = _usersBS.get(childUserId); TreeNode newNode = null; if (node == null) { node = new TreeNode(userEntity.ToString(i)); node.Tag = NodeItem.ToNodeItem(entity, i); node.ForeColor = Color.Green; treeView1.Nodes.Add(node); newNode = node; } else { newNode = new TreeNode(userEntity.ToString()); newNode.Tag = NodeItem.ToNodeItem(entity, i); newNode.ForeColor = Color.Green; node.Nodes.Add(newNode); } createTree(_userTreeBL.getByParent(parentId), newNode); } }
private ArrayList getReffers(DateTime fromDate, DateTime toDate) { ArrayList list = new ArrayList(); UsersEntity usersEntity = new UsersBS().get(""); for (int i = 0; i < usersEntity.RowCount(); i++) { object[] arr = new object[3]; arr[0] = usersEntity.ToString(i); arr[1] = getRefferFromCount(int.Parse(usersEntity.get(i, UsersEntity.FIELD_ID).ToString()), fromDate, toDate); arr[2] = getRefferToCount(int.Parse(usersEntity.get(i, UsersEntity.FIELD_ID).ToString()), fromDate, toDate); list.Add(arr); } return(list); }
private void fillGrid(string cond) { UsersEntity entity = null; if (cond.Length > 0) { cond += " AND "; } if (UnselectIds != null && UnselectIds.Length > 0) { cond += UsersEntity.FIELD_ID + " not in(" + UnselectIds + ")"; } if (!_showAdminUsers) { if (cond.Length > 0) { cond += " AND "; } cond += UsersEntity.FIELD_USER_TYPE + "<>" + UsersBS.ADMIN; } if (cond.Length > 0) { cond += "and"; } cond += " ACTIVE=1"; entity = _usersBS.get(cond); System.Collections.Hashtable hash = new Hashtable(); _gridTools.bindDataToGrid(dataGridView1, entity, null, hash); }
private string getUsers(int letterid) { string retStr = ""; ReferLetterEntity refLetterEntity = _referLetterBL.get(letterid); if (refLetterEntity.RowCount() <= 0) { return(""); } string fromName = ""; string toName = ""; string date = ""; UsersEntity usersEntity = null; for (int i = 0; i < refLetterEntity.RowCount(); i++) { date = RMX_TOOLS.date.DateXFormer.gregorianToPersianString((DateTime) refLetterEntity.get(i, ReferLetterEntity.FIELD_REFER_DATE)); if (refLetterEntity.get(i, ReferLetterEntity.FIELD_REFER_FROM_USER).ToString().Length > 0) { int id = int.Parse(refLetterEntity.get(i, ReferLetterEntity.FIELD_REFER_FROM_USER).ToString()); usersEntity = _usersBL.get(id); fromName = usersEntity.ToString(); } if (refLetterEntity.get(i, ReferLetterEntity.FIELD_REFER_TO_USER).ToString().Length > 0) { int id = int.Parse(refLetterEntity.get(i, ReferLetterEntity.FIELD_REFER_TO_USER).ToString()); usersEntity = _usersBL.get(id); toName = usersEntity.ToString(); } retStr += "[" + (i + 1) + "-" + date + " " + " از " + fromName + " به " + toName + "]"; } return(retStr); }
private void btnUpdate_Click(object sender, EventArgs e) { string check = checkData(); if (check != null) { MessageBox.Show(check); return; } if (dataGridView1.RowCount <= 0) { dataMode = NEW_MODE; } UsersEntity entity = new UsersEntity(); DataRow dr = null; dr = entity.Tables[entity.TableName].NewRow(); entity.FilledTableName = entity.TableName; dr[UsersEntity.FIELD_NAME] = txtName.Text; dr[UsersEntity.FIELD_FAMILY] = txtFamily.Text; dr[UsersEntity.FIELD_USERNAME] = txtUserName.Text; dr[UsersEntity.FIELD_PASSWORD] = txtPassword.Text; dr[UsersEntity.FIELD_USER_TYPE] = (cmbUserType.SelectedIndex + 1); dr[UsersEntity.FIELD_ACTIVE] = (cbActive.Checked ? 1 : 0); if (cmbLetterPattern.SelectedIndex >= 0) { ComboBoxItem item = (ComboBoxItem)cmbLetterPattern.Items[cmbLetterPattern.SelectedIndex]; dr[UsersEntity.FIELD_LETTER_PATTERN_ID] = item.Value; } if (!dataMode.Equals(NEW_MODE)) { dr[entity.IndexFieldName] = _gridTools.getCurrentRowValue(dataGridView1, entity.IndexFieldName); } object id = _gridTools.getCurrentRowValue(dataGridView1, entity.IndexFieldName); entity.Tables[entity.TableName].Rows.Add(dr); int count; if (dataMode.Equals(NEW_MODE)) { UsersEntity en = _usersBs.get(UsersEntity.FIELD_USERNAME + "='" + txtUserName.Text + "'"); if (en.Tables[en.FilledTableName].Rows.Count > 0) { MessageBox.Show("نام کاربری تعیین شده قبلا تعریف شده است، لطفا نام دیگری را انتخاب نمایید"); return; } count = _usersBs.add(entity); } else if (dataMode.Equals(EDIT_MODE)) { count = _usersBs.update(entity); } dataMode = EDIT_MODE; btnRefresh_Click(null, null); fillGrid(); }
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; } }