private void LoadCustomerInPage(int page) { if (page < 1) { this.PageNumber = 1; } else if (page > this.TotalPageNumber) { this.PageNumber = this.TotalPageNumber; } else { this.PageNumber = page; } DataGridViewCustomerInfo.ClearSelection(); DataTable dataTable = new DataTable(); if (this.UserName.Equals(AllUsers)) { dataTable = TableCustomerManage.QueryCustomerByPage(this.PageNumber, PageSize); } else { dataTable = TableCustomerManage.QueryCustomerByUserNameAndPage(this.UserName, this.PageNumber, PageSize); } DataGridViewCustomerInfo.DataSource = dataTable; FormatDataGridView(DataGridViewCustomerInfo); LblCurPage.Text = this.PageNumber + "/" + this.TotalPageNumber; }
private void TsmiDelete_Click(object sender, EventArgs e) { try { DialogResult dialogResult = MessageBox.Show(this, "您确定要删除所选客户信息吗,删除后将不可恢复?", this.Text, MessageBoxButtons.YesNo, MessageBoxIcon.Warning); if (DialogResult.Yes == dialogResult) { int count = DataGridViewCustomerInfo.SelectedRows.Count; for (int i = 0; i < count; i++) { var row = DataGridViewCustomerInfo.SelectedRows[i]; object objId = row.Cells["Id"].Value; int id = Convert.ToInt32(objId); int result = TableCustomerManage.DeleteCustomerById(id); if (result <= 0) { string email = row.Cells["Email"].Value.ToString(); MessageBox.Show(this, "删除客户 " + email + " 信息失败!", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Error); } } LoadCustomerInPage(this.PageNumber); } else if (DialogResult.No == dialogResult) { } } catch (Exception ex) { MessageBox.Show(this, ex.Message, this.Text, MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void LoadAllLogs(int CustomerId) { //DataSet dataSet = CFUSystem.QueryCustomerFollowUpLogsByEmail(this.Email); DataSet dataSet = TableCustomerManage.QueryFollowUpLogsByCustomerId(CustomerId); DataGridViewFollowUpLogs.DataSource = dataSet; DataGridViewFollowUpLogs.DataMember = "TB_CustomerFollowUpLogs"; FormatDataGridView(DataGridViewFollowUpLogs); }
private void RefreshCustomer() { if (this.UserName.Equals(AllUsers)) { this.TotalNumber = TableCustomerManage.QueryAllCustomerNumber(); } else { this.TotalNumber = TableCustomerManage.QueryCustomerNumberByUserName(this.User.Name); } this.TotalPageNumber = this.TotalNumber % PageSize == 0 ? this.TotalNumber / PageSize : this.TotalNumber / PageSize + 1; LoadCustomerInPage(1); }
private void BtnLogSave_Click(object sender, EventArgs e) { Cursor.Current = Cursors.WaitCursor; try { string email = this.FollowUpLog.Email = this.Customer.Email; // TxtBoxEmail.Text.Trim(); string company = this.FollowUpLog.CompanyName = this.Customer.CompanyName; // TxtBoxCompanyName.Text.Trim(); int number = this.FollowUpLog.Number = Convert.ToInt32(NumUpDownNumber.Value); string datetime = this.FollowUpLog.Time = DTPDate.Value.ToLocalTime().ToString(); string state = this.FollowUpLog.State = ComboBoxState.Text.Trim(); string briefing = this.FollowUpLog.Briefing = TxtBoxBriefing.Text.Trim(); string content = this.FollowUpLog.Content = RichTxtBoxContent.Text.Trim(); string modify = this.FollowUpLog.Modify = DateTime.Now.ToLocalTime().ToString(); string seller = this.FollowUpLog.BelongsTo = this.Customer.BelongsTo; if (WorkingState.Add == this.FollowUpWorkingState) { int identity = TableCustomerManage.AddFollowUpLogReturnIdentity(email, company, this.Customer.Id, number, datetime, state, briefing, content, modify, seller); if (identity > 0) { this.DialogResult = DialogResult.OK; this.Close(); } } else if (WorkingState.Modify == this.FollowUpWorkingState) { int num = TableCustomerManage.ModifyFollowUpLogById(this.FollowUpLog.Id, email, company, this.Customer.Id, number, state, briefing, content, modify, seller); if (num > 0) { this.DialogResult = DialogResult.OK; this.Close(); } } } catch (Exception ex) { MessageBox.Show(this, ex.Message, this.Text, MessageBoxButtons.OK, MessageBoxIcon.Error); } Cursor.Current = Cursors.Default; }