예제 #1
0
        private void initial()
        {
            Data categories = GlobalDb.getCategories();

            if (!categories.Success)
            {
                this.Close();
                return;
            }
            comboBoxCategory.DataSource    = categories.DataTable;
            comboBoxCategory.DisplayMember = "name";
            comboBoxCategory.ValueMember   = "id";

            Data statuses = GlobalDb.getStatuses();

            if (!statuses.Success)
            {
                this.Close();
                return;
            }
            comboBoxStatus.DataSource       = statuses.DataTable;
            comboBoxStatus.DisplayMember    = "name";
            comboBoxStatus.ValueMember      = "id";
            dateTimePickerCreatedDate.Value = DateTime.Today;
        }
예제 #2
0
        public UserProperties(int id)
        {
            InitializeComponent();
            initial();
            isCreating = false;
            userId     = id;
            User user = GlobalDb.getUser(id);

            if (user.id == 0)
            {
                MessageBox.Show("未找到此用户");
                this.Close();
            }
            textBoxName.Text      = user.name;
            textBoxCellPhone.Text = user.cellPhone;
            Store store = ShardDb.getStore(user.storeId);

            if (store.id == 0)
            {
                MessageBox.Show("未找到店铺");
                this.Close();
            }
            comboBoxStore.SelectedValue = user.storeId;
            comboBoxCity.SelectedValue  = store.cityId;
            comboBoxRole.SelectedValue  = user.roleId;
            textBoxMemo.Text            = user.memo;
            textBoxMail.Text            = user.mail;
            checkBoxActive.Checked      = user.active;
            buttonDelete.Visible        = !isCreating;
        }
예제 #3
0
        public TenantProperties(int id)
        {
            InitializeComponent();
            initial();
            isCreating = false;
            tenantId   = id;
            Tenant tenant = GlobalDb.getTenantById(id);

            if (tenant.id == 0)
            {
                MessageBox.Show("未找到此租户ID=0");
                this.Close();
            }
            textBoxName.Text                = tenant.name;
            textBoxShardName.Text           = tenant.shardName;
            dateTimePickerCreatedDate.Value = tenant.createdDate;
            comboBoxCategory.SelectedValue  = tenant.categoryId;
            comboBoxStatus.SelectedValue    = tenant.statusId;
            User user = GlobalDb.getUserByTenantId(tenant.id);

            userId = user.id;
            textBoxCellPhone.Text             = user.cellPhone;
            textBoxAdminName.Text             = user.name;
            textBoxMemo.Text                  = user.memo;
            textBoxMail.Text                  = user.mail;
            textBoxShardName.Enabled          = false;
            dateTimePickerCreatedDate.Enabled = false;
            buttonDelete.Visible              = !isCreating;
        }
예제 #4
0
파일: UserQuery.cs 프로젝트: wynet321/aimu
 private void buttonSearch_Click(object sender, EventArgs e)
 {
     if (validate())
     {
         Data users = GlobalDb.getUsers(Sharevariables.TenantId, Convert.ToInt16(comboBoxRoles.SelectedValue), textBoxCellPhone.Text.Trim(), textBoxName.Text.Trim());
         if (!users.Success)
         {
             this.Close();
             return;
         }
         dataGridViewTenants.DataSource                      = users.DataTable;
         dataGridViewTenants.Columns["id"].Visible           = false;
         dataGridViewTenants.Columns["cellphone"].HeaderText = "电话";
         dataGridViewTenants.Columns["name"].HeaderText      = "姓名";
         dataGridViewTenants.Columns["password"].Visible     = false;
         dataGridViewTenants.Columns["passwordSalt"].Visible = false;
         dataGridViewTenants.Columns["storeId"].Visible      = false;
         dataGridViewTenants.Columns["roleId"].Visible       = false;
         dataGridViewTenants.Columns["name1"].HeaderText     = "类型";
         dataGridViewTenants.Columns["name2"].HeaderText     = "城市";
         dataGridViewTenants.Columns["name3"].HeaderText     = "店名";
         dataGridViewTenants.Columns["mail"].HeaderText      = "邮件地址";
         dataGridViewTenants.Columns["memo"].HeaderText      = "备注";
         dataGridViewTenants.Columns["active"].HeaderText    = "状态";
     }
 }
예제 #5
0
        public TenantQuery()
        {
            InitializeComponent();
            Data categories = GlobalDb.getCategories();

            if (!categories.Success)
            {
                this.Close();
                return;
            }
            comboBoxCategory.DisplayMember = "name";
            comboBoxCategory.ValueMember   = "id";
            DataRow newRow = categories.DataTable.NewRow();

            newRow["id"]   = 0;
            newRow["name"] = "全部";
            categories.DataTable.Rows.InsertAt(newRow, 0);
            comboBoxCategory.DataSource = categories.DataTable;
            Data statuses = GlobalDb.getStatuses();

            if (!statuses.Success)
            {
                this.Close();
                return;
            }
            comboBoxStatus.DisplayMember = "name";
            comboBoxStatus.ValueMember   = "id";
            DataRow row = statuses.DataTable.NewRow();

            row["id"]   = 0;
            row["name"] = "全部";
            statuses.DataTable.Rows.InsertAt(row, 0);
            comboBoxStatus.DataSource = statuses.DataTable;
        }
예제 #6
0
 private void buttonDelete_Click(object sender, EventArgs e)
 {
     if (DialogResult.Yes == MessageBox.Show("", "", MessageBoxButtons.YesNo))
     {
         if (GlobalDb.deleteUser(userId))
         {
             this.Close();
         }
     }
 }
예제 #7
0
        private void buttonOk_Click(object sender, EventArgs e)
        {
            if (validate())
            {
                User user = new User();
                user.id           = userId;
                user.cellPhone    = textBoxCellPhone.Text.Trim();
                user.mail         = textBoxMail.Text.Trim();
                user.name         = textBoxAdminName.Text.Trim();
                user.roleId       = 1;
                user.storeId      = 0;
                user.memo         = textBoxMemo.Text.Trim();
                user.passwordSalt = PasswordEncryption.generateSalt();
                user.password     = PasswordEncryption.generatePassword(textBoxPassword.Text.Trim(), user.passwordSalt);
                user.active       = true;

                Tenant tenant = new Tenant();
                tenant.id             = tenantId;
                tenant.enableWorkFlow = checkBoxEnableWorkFlow.Checked;
                tenant.createdDate    = dateTimePickerCreatedDate.Value;
                tenant.categoryId     = Convert.ToUInt16(comboBoxCategory.SelectedValue);
                tenant.statusId       = Convert.ToUInt16(comboBoxStatus.SelectedValue);
                tenant.shardName      = textBoxShardName.Text.Trim();
                tenant.name           = textBoxName.Text.Trim();

                if (isCreating)
                {
                    if (GlobalDb.createTenant(tenant, user))
                    {
                        this.Close();
                    }
                    else
                    {
                        MessageBox.Show("新建失败! 请联系管理员!");
                    }
                }
                else
                {
                    //update
                    if (GlobalDb.updateTenant(tenant, user))
                    {
                        this.Close();
                    }
                    else
                    {
                        MessageBox.Show("更新失败! 请联系管理员!");
                    }
                }
            }
        }
예제 #8
0
        private bool validate(string username, string password)
        {
            User user = GlobalDb.getUserByCellPhone(textBoxUserName.Text);

            if (user.cellPhone.Length > 0)
            {
                if (PasswordEncryption.validate(password, user.password, user.passwordSalt))
                {
                    if (user.tenantId == 1)
                    {
                        //administrator of all tenants
                        Sharevariables.IsTenantAdministrator = true;
                        return(true);
                    }
                    Tenant tenant = GlobalDb.getTenantById(user.tenantId);
                    if (tenant.id != 0)
                    {
                        Sharevariables.EnableWorkFlow          = tenant.enableWorkFlow;
                        Sharevariables.ShardDbConnectionString = "server=" + PropertyHandler.HostName + ";uid=" + PropertyHandler.UserName + ";pwd=" + PropertyHandler.Password + ";database=" + tenant.shardName;
                        Sharevariables.UserName    = user.cellPhone.ToString();
                        Sharevariables.UserLevel   = user.roleId;
                        Sharevariables.StoreId     = user.storeId;
                        Sharevariables.UserAddress = user.mail;
                        Sharevariables.TenantId    = user.tenantId;
                        return(true);
                    }
                    else
                    {
                        MessageBox.Show("此用户的数据不存在!");
                        return(false);
                    }
                }
                else
                {
                    MessageBox.Show("用户名或密码错误!");
                    return(false);
                }
            }
            else
            {
                MessageBox.Show("用户名或者密码错误!");
                return(false);
            }
        }
예제 #9
0
파일: UserQuery.cs 프로젝트: wynet321/aimu
        public UserQuery()
        {
            InitializeComponent();
            Data roles = GlobalDb.getRoles();

            if (!roles.Success)
            {
                this.Close();
                return;
            }
            comboBoxRoles.DisplayMember = "name";
            comboBoxRoles.ValueMember   = "id";
            DataRow newRow = roles.DataTable.NewRow();

            newRow["id"]   = 0;
            newRow["name"] = "全部";
            roles.DataTable.Rows.InsertAt(newRow, 0);
            comboBoxRoles.DataSource = roles.DataTable;
        }
예제 #10
0
        private void buttonOk_Click(object sender, EventArgs e)
        {
            if (validate())
            {
                User user = new User();
                user.id           = userId;
                user.cellPhone    = textBoxCellPhone.Text.Trim();
                user.mail         = textBoxMail.Text.Trim();
                user.name         = textBoxName.Text.Trim();
                user.roleId       = Convert.ToInt16(comboBoxRole.SelectedValue);
                user.storeId      = Convert.ToInt16(comboBoxStore.SelectedValue);
                user.tenantId     = Sharevariables.TenantId;
                user.memo         = textBoxMemo.Text.Trim();
                user.passwordSalt = PasswordEncryption.generateSalt();
                user.password     = PasswordEncryption.generatePassword(textBoxPassword.Text.Trim(), user.passwordSalt);
                user.active       = checkBoxActive.Checked;

                if (isCreating)
                {
                    if (GlobalDb.createUser(user))
                    {
                        this.Close();
                    }
                    else
                    {
                        MessageBox.Show("新建失败! 请联系管理员!");
                    }
                }
                else
                {
                    //update
                    if (GlobalDb.updateUser(user))
                    {
                        this.Close();
                    }
                    else
                    {
                        MessageBox.Show("更新失败! 请联系管理员!");
                    }
                }
            }
        }
예제 #11
0
 private void buttonSearch_Click(object sender, EventArgs e)
 {
     if (validate())
     {
         string cellphone = textBoxCellPhone.Text.Trim();
         Data   tenants   = GlobalDb.getTenants(Convert.ToInt16(comboBoxStatus.SelectedValue), Convert.ToInt16(comboBoxCategory.SelectedValue), cellphone, textBoxName.Text.Trim());
         if (!tenants.Success)
         {
             this.Close();
             return;
         }
         dataGridViewTenants.DataSource                           = tenants.DataTable;
         dataGridViewTenants.Columns["id"].Visible                = false;
         dataGridViewTenants.Columns["name"].HeaderText           = "名称";
         dataGridViewTenants.Columns["shardName"].HeaderText      = "数据库名";
         dataGridViewTenants.Columns["statusid"].Visible          = false;
         dataGridViewTenants.Columns["categoryId"].Visible        = false;
         dataGridViewTenants.Columns["name1"].HeaderText          = "状态";
         dataGridViewTenants.Columns["name2"].HeaderText          = "类型";
         dataGridViewTenants.Columns["createdDate"].HeaderText    = "创建日期";
         dataGridViewTenants.Columns["enableWorkFlow"].HeaderText = "开启流程";
     }
 }
예제 #12
0
        private void initial()
        {
            Data roles = GlobalDb.getRoles();

            if (!roles.Success)
            {
                this.Close();
                return;
            }
            comboBoxRole.DataSource    = roles.DataTable;
            comboBoxRole.DisplayMember = "name";
            comboBoxRole.ValueMember   = "id";

            Data cities = ShardDb.getCities();

            if (!cities.Success)
            {
                this.Close();
                return;
            }
            comboBoxCity.DisplayMember = "name";
            comboBoxCity.ValueMember   = "id";
            comboBoxCity.DataSource    = cities.DataTable;
        }