private void FillDocumentMonthData() { objUtil = new UtilityDB(); try { string[] strBranchCode; DataTable dt; if (txtUserId.Text.Contains("admin")) { strBranchCode = cbCompany.SelectedValue.ToString().Split('@'); dt = objUtil.dtCompanyDocumentMonth(strBranchCode[0]); } else { strBranchCode = cbUserBranch.SelectedValue.ToString().Split('@'); dt = objUtil.dtCompanyDocumentMonth(strBranchCode[1]); } if (dt.Rows.Count > 0) { cbDocmentMonth.DisplayMember = "DocMonth"; cbDocmentMonth.ValueMember = "FinYear"; cbDocmentMonth.DataSource = dt; } } catch (Exception ex) { MessageBox.Show(ex.Message); } finally { objUtil = null; } }
private void FillTransactionType() { objUtilData = new UtilityDB(); try { DataTable dt = objUtilData.dtSPIntConvTranType(); if (dt.Rows.Count > 0) { TranTypeLoad = true; cmbTrnType.DataSource = dt; cmbTrnType.DisplayMember = "type"; cmbTrnType.ValueMember = "name"; } TranTypeLoad = false; } catch (Exception ex) { MessageBox.Show(ex.Message, "DC SP", MessageBoxButtons.OK, MessageBoxIcon.Stop); } finally { objUtilData = null; Cursor.Current = Cursors.Default; } }
private void SalesManager_Load(object sender, EventArgs e) { //Create an object of type DataSet and name it as CollegeDS dsHiTechOrderManagement = new DataSet("HiTechDS"); //Create an object of type DataTable and name it as Students // and add the object to the DataSet object dtCustomers = new DataTable("Customers"); dsHiTechOrderManagement.Tables.Add(dtCustomers); //dsCollegeDB.Tables.Add("Students"); // Create columns , add columns to the DataTable Students dtCustomers.Columns.Add("CustomerId", typeof(int)); dtCustomers.Columns.Add("FirstName", typeof(string)); dtCustomers.Columns.Add("LastName", typeof(string)); dtCustomers.Columns.Add("Street", typeof(string)); dtCustomers.Columns.Add("City", typeof(string)); dtCustomers.Columns.Add("PostalCode", typeof(string)); dtCustomers.Columns.Add("CreditLimit", typeof(int)); dtCustomers.Columns.Add("PhoneNumber", typeof(int)); dtCustomers.Columns.Add("FaxNumber", typeof(string)); dtCustomers.PrimaryKey = new DataColumn[] { dtCustomers.Columns["CustomerId"] }; da = new SqlDataAdapter("SELECT * FROM Customers", UtilityDB.ConnectDB()); SqlBuilder = new SqlCommandBuilder(da); }
private void FillDocMonth() { objUtil = new UtilityDB(); DataTable dt = new DataTable(); try { cbDocmonth.DataSource = null; dt = objUtil.dtCompanyDocumentMonth(CommonData.CompanyCode); if (dt.Rows.Count > 0) { cbDocmonth.DisplayMember = "DocMonth"; //cbDocmonth.ValueMember = "FinYear"; cbDocmonth.ValueMember = "DocMonth"; cbDocmonth.DataSource = dt; } } catch (Exception ex) { MessageBox.Show(ex.ToString()); } finally { dt = null; objUtil = null; } }
private void FillUserBranch() { objUtil = new UtilityDB(); try { DataTable dtUB = objUtil.dtUserBranch(txtUserId.Text.ToString()); //if (dtUB.Rows.Count == 0) dtUB.Rows.Add(CommonData.BranchCode + '@' + CommonData.CompanyCode + '@' + CommonData.BranchName + '@' + CommonData.CompanyName + '@' + CommonData.StateCode, CommonData.BranchName); cbUserBranch.DisplayMember = "branch_name"; cbUserBranch.ValueMember = "branch_Code"; cbUserBranch.DataSource = dtUB; //cbUserBranch.SelectedValue = CommonData.BranchCode + '@' + CommonData.CompanyCode + '@' + CommonData.BranchName + '@' + CommonData.CompanyName + '@' + CommonData.StateCode; dtUB = null; } catch (Exception ex) { MessageBox.Show(ex.Message); } finally { objUtil = null; } }
//public static Employee SearchPasswordById(int empId) //{ // Employee emp = new Employee(); // string sqlSelect = "SELECT * FROM Employees " + // "WHERE employeeId = " + empId; // SqlConnection sqlConn = UtilityDB.ConnectDB(); // SqlCommand sqlCmd = new SqlCommand(sqlSelect, sqlConn); // SqlDataReader sqlReader = sqlCmd.ExecuteReader(); // if (sqlReader.Read()) // { // emp.Password = sqlReader["Password"].ToString(); // } // else // { // emp = null; // } // sqlConn.Close(); // return emp; //} public static bool ValidatePassword(int empId, string password) { bool success = false; try { Employee emp = new Employee(); string sqlSelect = "SELECT * FROM Employees " + "WHERE employeeId = " + empId; SqlConnection sqlConn = UtilityDB.ConnectDB(); SqlCommand sqlCmd = new SqlCommand(sqlSelect, sqlConn); SqlDataReader sqlReader = sqlCmd.ExecuteReader(); if (sqlReader.Read()) { emp.Password = sqlReader["Password"].ToString(); } else { emp = null; } if (emp.Password == password) { success = true; } } catch (SqlException ex) { throw ex; } return(success); }
private void cbKhoa_SelectedIndexChanged(object sender, EventArgs e) { UtilityDB data = new UtilityDB(); string MaKhoa = cbKhoa.SelectedValue.ToString(); gvDanhSachLop.DataSource = data.getLop(MaKhoa, serverName, database, user, password); }
private void FillUSERRole() { objUtilDB = new UtilityDB(); try { DataTable dt = objUtilDB.dtUserRole(); if (dt.Rows.Count > 0) { foreach (DataRow dataRow in dt.Rows) { ComboboxItem objItem = new ComboboxItem(); objItem.Value = dataRow["name"].ToString(); objItem.Text = dataRow["name"].ToString(); cbRole.Items.Add(objItem); objItem = null; } } dt = null; } catch (Exception ex) { MessageBox.Show(ex.Message); } finally { objUtilDB = null; } }
private void buttonUpdate_Click(object sender, EventArgs e) { int searchId = Convert.ToInt32(textBoxClientId.Text); DataRow row = dtClient.Rows.Find(searchId); if (row != null) { row["ClientName"] = textBoxClientName.Text; row["Phone"] = maskedTextBoxPhone.Text; row["CreditLimit"] = float.Parse(textBoxCreditLimit.Text); row["StreetNumber"] = Convert.ToInt32(textBoxCreditLimit.Text); row["StreetName"] = textBoxStreetName.Text; row["City"] = textBoxCity.Text; row["PostalCode"] = textBoxPostalCode.Text; row["Province"] = textBoxProvince.Text; MessageBox.Show("In the DataSet obj, Student Info modified"); } if (dsClient.HasChanges()) //DB { sqlDa = UtilityDB.GetDataAdapterClients(); sqlCmdClient = new SqlCommandBuilder(sqlDa); sqlDa.Update(dsClient.Tables["Clients"]); MessageBox.Show("Database updated successfully.", "Update", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
private void FillBranchData() { objUtil = new UtilityDB(); DataTable dtUB = new DataTable(); try { dtUB = objUtil.dtUserBranch(CommonData.LogUserId); //if (dtUB.Rows.Count == 0) //dtUB.Rows.Add(CommonData.BranchCode + '@' + CommonData.CompanyCode + '@' + CommonData.BranchName + '@' + CommonData.CompanyName, CommonData.BranchName); cbUserBranch.DisplayMember = "branch_name"; cbUserBranch.ValueMember = "branch_Code"; cbUserBranch.DataSource = dtUB; cbUserBranch.SelectedIndex = 0; } catch (Exception ex) { MessageBox.Show(ex.Message); } finally { objUtil = null; dtUB = null; } }
private void salesButtonList_Click(object sender, EventArgs e) { labelDSInfo.Visible = false; LabelDBinfo.Visible = true; da = new SqlDataAdapter("SELECT * FROM Clients", UtilityDB.ConnectDB()); da.Fill(dsHiTech.Tables["Clients"]); dataGridViewSales.DataSource = dsHiTech.Tables["Clients"]; }
private void Sales_Load(object sender, EventArgs e) { dsHiTech = UtilityDB.InitializeDataSet(); dtClients = dsHiTech.Tables["Clients"]; //dataGridViewSales.DataSource = dsHiTech.Tables["Clients"]; }
private void rpvLop_Load(object sender, EventArgs e) { UtilityDB data = new UtilityDB(); cbKhoa.DataSource = data.getKhoa(); cbKhoa.DisplayMember = "TenKhoa"; cbKhoa.ValueMember = "MaKhoa"; }
private void frmLop_Load(object sender, EventArgs e) { UtilityDB data = new UtilityDB(); cbKhoa.DataSource = data.getKhoa(serverName, database, user, password); cbKhoa.DisplayMember = "Tên Khoa"; cbKhoa.ValueMember = "Mã Khoa"; }
private void cbKhoa_SelectedIndexChanged(object sender, EventArgs e) { if (cbKhoa.SelectedIndex != -1) { UtilityDB data = new UtilityDB(); string MaKhoa = cbKhoa.SelectedValue.ToString(); gvLop.DataSource = data.getLop(MaKhoa); } }
private void btnHienThi_Click(object sender, EventArgs e) { //string sql = "select * from lop, khoa where Lop.MaKhoa=Khoa.MaKhoa and Lop.MaKhoa='" + cbKhoa.SelectedValue + "'"; string sql = "SELECT * FROM LOP, KHOA WHERE LOP.MaKhoa = KHOA.MaKhoa AND LOP.MaKhoa = '" + cbKhoa.SelectedValue + "'"; CrystalReportLop crtLop = new CrystalReportLop(); UtilityDB data = new UtilityDB(); crtLop.SetDataSource(data.getDataInTable(sql)); rpvLop.ReportSource = crtLop; rpvLop.Refresh(); }
private void FillBranches() { objInv = new InvoiceDB(); objUtilityDB = new UtilityDB(); DataSet ds = new DataSet(); if (CommonData.LogUserId.ToUpper() == "ADMIN") { ds = objInv.AdminBranchCursor_Get("", "", "PARENT"); } else { ds = objUtilityDB.UserBranchCursor_Get(CommonData.LogUserId, "", "", "PARENT"); } ttvBranch.Nodes.Add("Branches", "Branches"); if (ds.Tables[0].Rows.Count > 0) { for (int i = 0; i < ds.Tables[0].Rows.Count; i++) { ttvBranch.Nodes[0].Nodes.Add(ds.Tables[0].Rows[i]["COMPANY_CODE"].ToString(), ds.Tables[0].Rows[i]["COMPANY_NAME"].ToString()); DataSet dschild = new DataSet(); if (CommonData.LogUserId.ToUpper() == "ADMIN") { //if (sRep_Type == "SP_CHECKLIST") // dschild = objInv.AdminBranchCursor_Get(ds.Tables[0].Rows[i]["COMPANY_CODE"].ToString(), "SP", "CHILD"); //else dschild = objInv.AdminBranchCursor_Get(ds.Tables[0].Rows[i]["COMPANY_CODE"].ToString(), "BR", "CHILD"); } else { //if (sRep_Type == "SP_CHECKLIST") // dschild = objUtilityDB.UserBranchCursor_Get(CommonData.LogUserId, ds.Tables[0].Rows[i]["COMPANY_CODE"].ToString(), "SP", "CHILD"); //else dschild = objUtilityDB.UserBranchCursor_Get(CommonData.LogUserId, ds.Tables[0].Rows[i]["COMPANY_CODE"].ToString(), "BR", "CHILD"); } //tvBranches.Nodes[i].Nodes.Add("BRANCHES" + "(" + dschild.Tables[0].Rows.Count + ")"); if (dschild.Tables[0].Rows.Count > 0) { for (int j = 0; j < dschild.Tables[0].Rows.Count; j++) { ttvBranch.Nodes[0].Nodes[i].Nodes.Add(dschild.Tables[0].Rows[j]["BRANCH_CODE"].ToString(), dschild.Tables[0].Rows[j]["BRANCH_NAME"].ToString()); } } } } if (ds.Tables[0].Rows.Count > 0) { this.ttvBranch.SelectedNode = ttvBranch.Nodes[0]; this.ttvBranch.SelectedNode.Expand(); } }
private void btnXoa_Click(object sender, EventArgs e) { string malop = txtMaLop.Text; UtilityDB data = new UtilityDB(); bool kq = data.deleteLop(malop, serverName, database, user, password); if (kq == true) { MessageBox.Show("Xóa khoa có mã khoa " + malop + " thành công", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { MessageBox.Show("Xóa khoa có mã khoa " + malop + " thất bại", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void btnXoa_Click(object sender, EventArgs e) { string makhoa = txtMaKhoa.Text; UtilityDB data = new UtilityDB(); bool kq = data.deleteKhoa(makhoa); if (kq == true) { MessageBox.Show("Xóa khoa có mã khoa " + makhoa + " thành công", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information); HienDanhSachKhoaLenDataGridView(); } else { MessageBox.Show("Xóa khoa có mã khoa " + makhoa + " thất bại", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void btnSua_Click(object sender, EventArgs e) { string malop = txtMaLop.Text; string tenlop = txtTenLop.Text; UtilityDB data = new UtilityDB(); bool kq = data.updateLop(malop, tenlop); if (kq == true) { MessageBox.Show("Sửa khoa có mã khoa " + malop + " thành công", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { MessageBox.Show("Sửa khoa có mã khoa " + malop + " thất bại", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void btnCapNhat_Click(object sender, EventArgs e) { string makhoa = txtMaKhoa.Text; string tenkhoa = txtTenKhoa.Text; UtilityDB data = new UtilityDB(); bool kq = data.createKhoa(makhoa, tenkhoa, serverName, database, user, password); if (kq == true) { MessageBox.Show("Thêm khoa có mã khoa " + makhoa + " thành công", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information); HienDanhSachKhoaLenDataGridView(); } else { MessageBox.Show("Thêm khoa có mã khoa " + makhoa + " thất bại", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void btnLuu_Click(object sender, EventArgs e) { string malop = txtMaLop.Text; string tenlop = txtTenLop.Text; string makhoa = cbKhoa.SelectedValue.ToString(); UtilityDB data = new UtilityDB(); bool kq = data.createLop(malop, tenlop, makhoa, serverName, database, user, password); if (kq == true) { MessageBox.Show("Thêm khoa có mã khoa " + tenlop + " thành công", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { MessageBox.Show("Thêm khoa có mã khoa " + tenlop + " thất bại", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void btnLuu_Click(object sender, EventArgs e) { try { //xác dịnh vị trí của file cấu hình string path = Application.StartupPath + @"\configDB.txt"; string[] lines = { @"Server=" + txtServerName.Text, "Database=" + txtDatabaseName.Text, "User="******"Pass="******"Không thể kết nối cơ sở dữ liệu, kiểm tra lại thông tin kết nối"); } } catch (Exception ex) { MessageBox.Show("Có lỗi khi ghi file cấu hình"); } }
private void buttonDelete_Click(object sender, EventArgs e) { int deleteId = Convert.ToInt32(textBoxClientId.Text); //delete local DataRow dr = dtClient.Rows.Find(deleteId); if (dr != null) { dr.Delete(); MessageBox.Show("The Client was deleted."); } if (dsClient.HasChanges()) //Update DB { sqlDa = UtilityDB.GetDataAdapterClients(); sqlCmdClient = new SqlCommandBuilder(sqlDa); sqlDa.Update(dsClient.Tables["Clients"]); MessageBox.Show("Database updated successfully.", "Update", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
private void btnSave_Click(object sender, EventArgs e) { string strSQl = string.Empty; objData = new SQLDB(); objUtil = new UtilityDB(); string strFBNo = string.Empty; try { if (CheckData()) { objUserTask = new UserTaskDB(); strFBNo = objUserTask.GenerateFeedBackTranNo().ToString(); strSQl = " INSERT into CRM_FEEDBACK (CF_COMPANY_CODE , CF_STATE_CODE, CF_BRANCH_CODE, CF_FIN_YEAR,CF_TRN_TYPE,CF_TRN_NUMBER,CF_TRN_DATE,CF_TRN_REM,CF_CREATED_BY,CF_CREATED_DATE)" + " VALUES('" + CommonData.CompanyCode + "', '" + CommonData.StateCode + "', '" + CommonData.BranchCode + "', '" + CommonData.FinancialYear + "', '" + cbFeedBackType.Text + "', '" + strFBNo + "', '" + Convert.ToDateTime(CommonData.CurrentDate).ToString("dd/MMM/yyyy") + "', '" + txtFeedBack.Text + "', '" + CommonData.LogUserId + "', '" + Convert.ToDateTime(CommonData.CurrentDate).ToString("dd/MMM/yyyy") + "' )"; int rec = objData.ExecuteSaveData(strSQl); if (rec > 0) { objUtil.SendMail(CommonData.LogUserEcode + "-" + CommonData.LogUserName, CommonData.BranchName, txtFeedBack.Text); } txtFeedBack.Text = ""; FillFeedBackList(); } } catch (Exception ex) { MessageBox.Show(ex.Message, "Feed back", MessageBoxButtons.OK, MessageBoxIcon.Error); } finally { } }
private void FillBranchList() { objUtil = new UtilityDB(); DataTable dt = null; //string sqlText = ""; try { if (strRep == "STOCKPOINT_DC" || strRep == "STOCKPOINT_DCST" || strRep == "STOCKPOINT_GRN" || strRep == "STOCK_REC" || strRep == "STOCK_SUMMARY" || strRep == "STOCK_LEDGER" || strRep == "STOCKPOINT_RECONSILATION" || strRep == "SP_PENDING_DC") { dt = objUtil.UserBranch(CommonData.LogUserId, "SP"); } else if (strRep == "VEHICLE_LOAN" || strRep == "VEHICLE_INFO" || strRep == "SALES_STAFF_ALL" || strRep == "SaleSummaryBulletin" || strRep == "SERVICE_CONSOLIDATION") { dt = objUtil.UserBranch(CommonData.LogUserId, "BR"); } else { dt = objUtil.dtUserBranch(CommonData.LogUserId); } clbGLList.Items.Clear(); foreach (DataRow dataRow in dt.Rows) { if (dataRow["branch_Code"] + "" != "") { NewCheckboxListItem oclBox = new NewCheckboxListItem(); oclBox.Tag = dataRow["branch_Code"].ToString(); oclBox.Text = dataRow["branch_name"].ToString(); clbGLList.Items.Add(oclBox); oclBox = null; } } } catch (Exception ex) { MessageBox.Show(ex.Message); } finally { objStfLvl = null; } }
private void buttonList_Click(object sender, EventArgs e) { listViewClient.Items.Clear(); dsClient = UtilityDB.GetDataSetClients(dsClient, dtClient); foreach (DataRow row in dtClient.Rows) { ListViewItem item = new ListViewItem(row["ClientId"].ToString()); item.SubItems.Add(row["ClientName"].ToString()); item.SubItems.Add(row["Phone"].ToString()); item.SubItems.Add(row["CreditLimit"].ToString()); item.SubItems.Add(row["StreetNumber"].ToString()); item.SubItems.Add(row["StreetName"].ToString()); item.SubItems.Add(row["City"].ToString()); item.SubItems.Add(row["PostalCode"].ToString()); item.SubItems.Add(row["Province"].ToString()); listViewClient.Items.Add(item); } }
private void ManagerForm_Load(object sender, EventArgs e) { dsHiTechDB = new DataSet("HiTechDS"); dtCustomers = new DataTable("Customers"); dtCustomers.Columns.Add("CustomerId", typeof(Int32)); dtCustomers.Columns.Add("CustomerName", typeof(string)); dtCustomers.Columns.Add("Street", typeof(string)); dtCustomers.Columns.Add("City", typeof(string)); dtCustomers.Columns.Add("PostalCode", typeof(string)); dtCustomers.Columns.Add("PhoneNumber", typeof(string)); dtCustomers.Columns.Add("FaxNumber", typeof(string)); dtCustomers.Columns.Add("CreditLimit", typeof(float)); dtCustomers.PrimaryKey = new DataColumn[] { dtCustomers.Columns["CustomerId"] }; dsHiTechDB.Tables.Add(dtCustomers); //MessageBox.Show(dsHiTechDB.Tables.Count.ToString()); //MessageBox.Show(dsHiTechDB.Tables["Students"].ToString()); da = new SqlDataAdapter("SELECT * FROM Customers", UtilityDB.ConnectDB()); da.Fill(dsHiTechDB.Tables["Customers"]); //dataGridViewStudent.DataSource = dsHiTechDB.Tables["Students"]; }
private void FillBranchData() { objMaster = new Master(); objUtility = new UtilityDB(); try { cbBranchType.DataSource = objUtility.dtBranchType(); cbBranchType.ValueMember = "type"; cbBranchType.DisplayMember = "name"; cbStates.SelectedIndex = 0; cbBranchType.SelectedIndex = 0; } catch (Exception ex) { MessageBox.Show(ex.Message, "Add Branch", MessageBoxButtons.OK, MessageBoxIcon.Error); } finally { objMaster = null; } }
private void FillBranchType() { objMaster = new Master(); objUtility = new UtilityDB(); try { cbBranchType.DataSource = objUtility.dtBranchType(); cbBranchType.ValueMember = "type"; cbBranchType.DisplayMember = "name"; cbBranchType.SelectedValue = CommonData.BranchType; if (cbBranchType.SelectedIndex > 0) { FillBranchComboBox(); } } catch (Exception ex) { MessageBox.Show(ex.Message, "Add Outlet", MessageBoxButtons.OK, MessageBoxIcon.Error); } finally { objMaster = null; } }