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 void initTree() { UsersEntity entity = _usersBS.get(UsersEntity.FIELD_USER_TYPE + "=" + UsersBS.ADMIN); UserTreeEntity userTreeEntity = null; for (int i = 0; i < entity.Tables[entity.FilledTableName].Rows.Count; i++) { userTreeEntity = new UserTreeEntity(); DataRow dr = userTreeEntity.Tables[userTreeEntity.TableName].NewRow(); dr[UserTreeEntity.FIELD_USER_ID] = entity.get(UsersEntity.FIELD_ID); dr[UserTreeEntity.FIELD_USER_PATH] = entity.get(UsersEntity.FIELD_ID).ToString(); userTreeEntity.Tables[userTreeEntity.TableName].Rows.Add(dr); _userTreeBL.add(userTreeEntity); } userTreeEntity = _userTreeBL.get(); for (int i = 0; i < userTreeEntity.Tables[userTreeEntity.FilledTableName].Rows.Count; i++) { entity = _usersBS.get(int.Parse(userTreeEntity.get(UserTreeEntity.FIELD_USER_ID).ToString())); TreeNode node = new TreeNode(entity.ToString()); node.ForeColor = Color.Green; node.Tag = NodeItem.ToNodeItem(userTreeEntity, i); treeView1.Nodes.Add(node); } }
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 mnuAddUser_Click(object sender, EventArgs e) { TreeNode parentNode = (TreeNode)contextMenuStrip.Tag; NodeItem parentNodeItem = (NodeItem)parentNode.Tag; //show user List UserList list = new UserList(); string childs = _userTreeBL.getAllChildsIds(parentNodeItem.Id); list.UnselectIds = parentNodeItem.UserPath.Replace("/", ",") + (childs.Length > 0? "," + childs : ""); list.initList(); list.ShowAdminUsers = false; list.ShowDialog(); //prepare to create node and save it to database and also show in tree string name = list.UserName; int userid = list.Id; if (userid > 0) // if any user selected { //بررسی تکراری وارد نکردن کاربر if (("/" + parentNodeItem.UserPath + "/").IndexOf("/" + userid + "/") >= 0) { MessageBox.Show("کاربری که اضافه می کنید در سطوح بالاتر وجود دارد، امکان اضافه کردن کاربر تکراری وجود ندارد"); return; } //create entity UserTreeEntity userTreeEntity = new UserTreeEntity(); DataRow dr = userTreeEntity.Tables[userTreeEntity.TableName].NewRow(); dr[UserTreeEntity.FIELD_USER_ID] = userid; dr[UserTreeEntity.FIELD_PARENT_ID] = parentNodeItem.Id; dr[UserTreeEntity.FIELD_USER_PATH] = parentNodeItem.UserPath + "/" + userid; //add entity to database userTreeEntity.Tables[userTreeEntity.TableName].Rows.Add(dr); int newid = _userTreeBL.add(userTreeEntity); dr[UserTreeEntity.FIELD_ID] = newid; userTreeEntity.FilledTableName = userTreeEntity.TableName; //create node and add it to Tree UsersEntity entity = _usersBS.get(userid); TreeNode node = new TreeNode(entity.ToString()); node.Tag = NodeItem.ToNodeItem(userTreeEntity); parentNode.Nodes.Add(node); parentNode.Expand(); } }
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; } }