Esempio n. 1
0
 public void intiForm()
 {
     if (Constants.DELETE_MODE.Equals(Mode))
     {
         pnlContainer.Visible = false;
         btnSave.Visible      = false;
         if (Id < 0)
         {
             return;
         }
         _entity = _basicInfoBL.get(_id);
         string s = _entity.get(BasicInfoEntity.FIELD_USERCANCHANGE).ToString();
         bool   b = false;
         if (s != null && s.Length > 0)
         {
             b = Boolean.Parse(s);
         }
         if (b)
         {
             lblMsg.ForeColor = Color.Red;
             lblMsg.Text      = "امکان حذف این مورد وجود ندارد";
             return;
         }
         doDelete();
         return;
     }
     if (_entity != null)
     {
         _id   = int.Parse(_entity.get(BasicInfoEntity.FIELD_ID).ToString());
         _mode = RMX_TOOLS.global.Constants.EDIT_MODE;
     }
     else if (_id > 0)
     {
         _mode   = RMX_TOOLS.global.Constants.EDIT_MODE;
         _entity = _basicInfoBL.get(_id);
         loadForm();
     }
     else
     {
         _mode   = RMX_TOOLS.global.Constants.ADD_MODE;
         _entity = new BasicInfoEntity();
     }
 }
Esempio n. 2
0
        public static void fillComboBox(ComboBox cmb, int parentId, int defaultItemId)
        {
            BasicInfoEntity parentEntity    = _basicInfoBL.get(parentId);
            Boolean         containsUnknown = false;
            string          c = parentEntity.get(BasicInfoEntity.FIELD_CONTAINUNKNOWN).ToString();

            if (c != null && c.Trim().Length > 0)
            {
                containsUnknown = Boolean.Parse(c);
            }

            BasicInfoEntity entity     = _basicInfoBL.getByParentId(parentId);
            var             dataSource = new List <ComboBoxItem>();

            try
            {
                cmb.Items.Clear();
            }
            catch (Exception ex) { }
            if (containsUnknown == true)
            {
                AddUnKnown(dataSource);
            }

            for (int i = 0; i < entity.Tables[entity.FilledTableName].Rows.Count; i++)
            {
                string id         = entity.Tables[entity.FilledTableName].Rows[i][BasicInfoEntity.FIELD_ID].ToString();
                string desc       = entity.Tables[entity.FilledTableName].Rows[i][BasicInfoEntity.FIELD_DESCRIPTION].ToString();
                string customData = "";
                if (entity.Tables[entity.FilledTableName].Rows[i][BasicInfoEntity.FIELD_CUSTOMFIELD] != null)
                {
                    customData = entity.Tables[entity.FilledTableName].Rows[i][BasicInfoEntity.FIELD_CUSTOMFIELD].ToString();
                }

                dataSource.Add(new ComboBoxItem(desc, id, customData));
            }

            // is inActive? or not
            BasicInfoEntity niEntity = _basicInfoBL.get(defaultItemId);

            if (niEntity.Tables[niEntity.FilledTableName].Rows.Count > 0)
            {
                bool isActive = bool.Parse(niEntity.Tables[niEntity.FilledTableName].Rows[0][BasicInfoEntity.FIELD_ACTIVE].ToString());;
                if (isActive == false)
                {
                    string id         = niEntity.Tables[niEntity.FilledTableName].Rows[0][BasicInfoEntity.FIELD_ID].ToString();
                    string desc       = niEntity.Tables[niEntity.FilledTableName].Rows[0][BasicInfoEntity.FIELD_DESCRIPTION].ToString();
                    string customData = "";
                    if (niEntity.Tables[niEntity.FilledTableName].Rows[0][BasicInfoEntity.FIELD_CUSTOMFIELD] != null)
                    {
                        customData = niEntity.Tables[entity.FilledTableName].Rows[0][BasicInfoEntity.FIELD_CUSTOMFIELD].ToString();
                    }

                    dataSource.Add(new ComboBoxItem(desc, id, customData));
                }
            }
            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(defaultItemId.ToString()))
                {
                    cmb.SelectedIndex = i;
                    break;
                }
            }
        }