Exemplo n.º 1
0
        public frmEditUser(UserInfo contact, IDXMenuManager menuManager)
        {
            InitializeComponent();
            this.contact = contact;
            this.bindingContact = contact.Clone();
            InitEditors();
            InitMenuManager(menuManager);
            peUserPhoto.Image = bindingContact.Photo;

            teUserID.DataBindings.Add("Text", bindingContact, "Id");    // Id
            tePassword.DataBindings.Add("Text", bindingContact, "Password");
            teConfirmPassword.DataBindings.Add("Text", bindingContact, "ConfirmPassword");
            icbUserLevel.DataBindings.Add("EditValue", bindingContact, "Level");    // Level
            teUserName.DataBindings.Add("Text", bindingContact, "Name");    // Name
            teUserPhone.DataBindings.Add("Text", bindingContact, "Phone");  // Phone
            meNotes.DataBindings.Add("Text", bindingContact, "Note");
            UpdateCaption();
            InitValidationProvider();
        }
Exemplo n.º 2
0
        protected internal override void ButtonClick(string tag) {
            switch(tag) {
                case TagResources.ContactList:
                    UpdateMainView(gridView1);
                    ClearSortingAndGrouping();
                    break;
                case TagResources.ContactAlphabetical:
                    UpdateMainView(gridView1);
                    ClearSortingAndGrouping();
                    colUserID.Group();
                    break;
                //case TagResources.ContactByState:
                //    UpdateMainView(gridView1);
                //    ClearSortingAndGrouping();
                //    colUserName.Group();
                //    colCity.SortOrder = DevExpress.Data.ColumnSortOrder.Ascending;
                //    break;
                case TagResources.ContactCard:
                    UpdateMainView(layoutView1);
                    break;
                case TagResources.FlipLayout:
                    layoutControl1.Root.FlipLayout();
                    break;
                case TagResources.ContactDelete:
                    if(CurrentContact == null) return;
                    int index = gridView1.FocusedRowHandle;
                    gidControlUserManage.MainView.BeginDataUpdate();
                    try
                    {
                        DeleteUserInfo(CurrentContact);
                        DataHelper.UserInfos.Remove(CurrentContact);
                        
                    }
                    finally
                    {
                        gidControlUserManage.MainView.EndDataUpdate();
                    }
                    if(index > gridView1.DataRowCount - 1) index--;
                    gridView1.FocusedRowHandle = index;
                    ShowInfo(gridView1);
                    break;
                case TagResources.ContactNew:
                    UserInfo contact = new UserInfo();
                    if(EditUser(contact) == DialogResult.OK) {
                        gidControlUserManage.MainView.BeginDataUpdate();
                        try
                        {
                            DataHelper.UserInfos.Add(contact);
                            InsertUserInfo(contact);

                        }
                        finally
                        {
                            gidControlUserManage.MainView.EndDataUpdate();
                        }
                        ColumnView view = gidControlUserManage.MainView as ColumnView;
                        if(view != null) {
                            GridHelper.GridViewFocusObject(view, contact);
                            ShowInfo(view);
                        }
                    }
                    break;
                case TagResources.ContactEdit:
                    if (EditUser(CurrentContact) == DialogResult.OK)
                    {
                        UpdateUserInfo(CurrentContact);
                    }

                    break;
            }
            UpdateCurrentContact();
            UpdateInfo();
        }
Exemplo n.º 3
0
        protected override void InitMDBData(string connectionString)
        {

            MariaDbConnection = new MySqlConnection(connectionString);
            MariaDbConnection.Open();
            MySqlManage sql = new MySqlManage(ConfigurationManager.ConnectionStrings["MySQL"].ConnectionString);
            DataSet ds = new DataSet();
            ds = sql.SelectMariaDBTable(MariaDbConnection, "SELECT * FROM AMR_MST06");
            

            foreach( DataRow row in ds.Tables[0].Rows)
            {
                UserInfo contact = new UserInfo();

                contact.Id = row["MST06AID"].ToString();
                if (row["MST06LEV"].ToString() == "1")
                {
                    contact.Level = UserLevel.Level1;
                }
                else if (row["MST06LEV"].ToString() == "2")
                {
                    contact.Level = UserLevel.Level2;
                }
                else if (row["MST06LEV"].ToString() == "3")
                {
                    contact.Level = UserLevel.Level3;
                }

                contact.Name = row["MST06NAM"].ToString();
                contact.Phone = row["MST06PHN"].ToString();
                contact.Password = row["MST06PWD"].ToString();
                contact.ConfirmPassword = row["MST06PWD"].ToString();

                DataHelper.UserInfos.Add(contact);
            }
            
            gidControlUserManage.DataSource = DataHelper.UserInfos;

        }
Exemplo n.º 4
0
 DialogResult EditUser(UserInfo contact)
 {
     if(contact == null) return DialogResult.Ignore;
     DialogResult ret = DialogResult.Cancel;
     Cursor.Current = Cursors.WaitCursor;
     using (frmEditUser frm = new frmEditUser(contact, OwnerForm.Ribbon))
     {
         ret = frm.ShowDialog(OwnerForm);
     }
     UpdateCurrentContact();
     Cursor.Current = Cursors.Default;
     return ret;
 }
Exemplo n.º 5
0
        void DeleteUserInfo(UserInfo contact)
        {
            MySqlDataReader Reader;
            MySqlCommand command = MariaDbConnection.CreateCommand();

            string sql = string.Format("delete from AMR_MST06 where MST06AID = '{0}'", contact.Id);


            command.CommandText = sql;

            Reader = command.ExecuteReader();
            Reader.Close();
        }
Exemplo n.º 6
0
        void UpdateUserInfo(UserInfo contact)
        {
            MySqlDataReader Reader;
            MySqlCommand command = MariaDbConnection.CreateCommand();
  

            int level = 0;
            if (contact.Level == UserLevel.Level1)
                level = 1;
            else if (contact.Level == UserLevel.Level2)
                level = 2;
            else if (contact.Level == UserLevel.Level3)
                level = 3;
            string sql = string.Format("update AMR_MST06 set MST06AID = '{0}', MST06LEV = '{1}', MST06NAM = '{2}', MST06PHN = '{3}', MST06PWD = '{4}' where MST06AID = '{5}'",
                contact.Id, level, contact.Name, contact.Phone, contact.Password, contact.Id);


            command.CommandText = sql;

            Reader = command.ExecuteReader();
            Reader.Close();

        }
Exemplo n.º 7
0
        void InsertUserInfo(UserInfo contact)
        {

            MySqlDataReader Reader;
            MySqlCommand command = MariaDbConnection.CreateCommand();
  
            int level = 0;
            if (contact.Level == UserLevel.Level1)
                level = 1;
            else if (contact.Level == UserLevel.Level2)
                level = 2;
            else if (contact.Level == UserLevel.Level3)
                level = 3;
            string sql = string.Format("insert into AMR_MST06 values('{0}', '{1}', '{2}', '{3}', '{4}')", contact.Id, contact.Password, contact.Name, level, contact.Phone);
            command.CommandText = sql;

            Reader = command.ExecuteReader();
            Reader.Close();
        }
Exemplo n.º 8
0
 public void Assign(UserInfo userinfo)
 {
     this.id = userinfo.id;
     this.password = userinfo.password;
     this.confirmPassword = userinfo.confirmPassword;
     this.level = userinfo.level;
     this.name = userinfo.name;
     this.phone = userinfo.Phone;
     this.note = userinfo.Note;
 }
Exemplo n.º 9
0
 public UserInfo(UserInfo userinfo)
 {
     this.Assign(userinfo);
 }
Exemplo n.º 10
0
 //object GetTasksData(Contact contact) {
 //    IEnumerable ret = from task in DataHelper.Tasks
 //           where task.AssignTo == contact
 //           select task;
 //    return ret.Cast<Task>().ToList();
 //}
 object GetTasksData(UserInfo contact)
 {
     IEnumerable ret = from task in DataHelper.Tasks
                       where task.AssignTo2 == contact
                       select task;
     return ret.Cast<Task>().ToList();
 }
Exemplo n.º 11
0
 //public NavBarData(object data, Contact contact) {
 //    this.contact = contact;
 //    this.data = data;
 //}
 public NavBarData(object data, UserInfo contact)
 {
     this.contact = contact;
     this.data = data;
 }
Exemplo n.º 12
0
 //NavBarItemLink AddNavBarItem(NavBarGroup group, string caption, Image image, object data, Contact contact) {
 //    NavBarItem item = new NavBarItem(caption);
 //    item.SmallImage = image;
 //    item.Tag = new NavBarData(data, contact);
 //    tasks.Add(item.Tag, data);
 //    NavBarItemLink link = group.ItemLinks.Add(item);
 //    item.LinkClicked += new NavBarLinkEventHandler(item_LinkClicked);
 //    return link;
 //}
 NavBarItemLink AddNavBarItem(NavBarGroup group, string caption, Image image, object data, UserInfo contact)
 {
     NavBarItem item = new NavBarItem(caption);
     item.SmallImage = image;
     item.Tag = new NavBarData(data, contact);
     tasks.Add(item.Tag, data);
     NavBarItemLink link = group.ItemLinks.Add(item);
     item.LinkClicked += new NavBarLinkEventHandler(item_LinkClicked);
     return link;
 }