private void AddVend_Click(object sender, EventArgs e) { string txtVendCode = VendorCode.Text; string txtVendName = VendorName.Text; if (VendorName.Text != "") { //search if existing if (!isExisting(txtVendName, VendorList)) { dbConnect.Insert("insert into tblVendor values('" + txtVendCode + "','" + txtVendName + "',false);"); } //Generate new Vendor Code this.VendorCode.Text = codeGenerator.generateCodeParent("tblVendor", "strVendCode", "Vendor"); //refresh VendorList refreshVendors(); VendorName.Clear(); this.Close(); } else { MessageBox.Show("Input a Vendor name"); } }
private void AddPosi_Click(object sender, EventArgs e) { string txtPosiCode = tbxPosiCode.Text; string txtPosiName = tbxPosiName.Text; string txtDepCode = getDepartmentCodeFromList(cmbDepName.SelectedItem.ToString()); if (tbxPosiName.Text != "") { //search if existing if (!isExisting(txtPosiName, PositionList)) { dbConnect.Insert("insert into tblPosition values('" + txtPosiCode + "','" + txtDepCode + "','" + txtPosiName + "',false);"); tbxPosiName.Clear(); this.Close(); } } else { MessageBox.Show("Input a Position name"); } //for if it didnt changed index generate code and refreshpositions //----generate this.tbxPosiCode.Text = codeGenerator.generateCodeChild("tblPosition", "strPosiCode", getDepartmentCodeFromList(cmbDepName.SelectedItem.ToString()), this.cmbDepName.SelectedItem.ToString() + "Pos"); //----refresh position according to dep if (this.cmbDepName.SelectedIndex != -1) { refreshPositions(getDepartmentCodeFromList(cmbDepName.SelectedItem.ToString())); } }
private void AddDepart_Click(object sender, EventArgs e) { string txtDepCode = DeptCode.Text; string txtDepName = DeptName.Text; if (DeptName.Text != "") { //search if existing if (!isExisting(txtDepName, DepartmentList)) { dbConnect.Insert("insert into tblDepartment values('" + txtDepCode + "','" + txtDepName + "',false);"); DeptName.Clear(); this.Close(); } } else { MessageBox.Show("Input a Department name"); } //Generate new Department Code this.DeptCode.Text = codeGenerator.generateCodeParent("tblDepartment", "strDepCode", "Dep"); //refresh DepartmentList refreshDepartments(); }
private void AddCateg_Click(object sender, EventArgs e) { string txtCategCode = CategoryCode.Text; string txtCategName = CategoryName.Text; if (CategoryName.Text != "") { if (!isExisting(txtCategName, CategoryList)) { dbConnect.Insert("insert into tblCategory values('" + txtCategCode + "','" + txtCategName + "',false);"); } //Generate nnew Category Code this.CategoryCode.Text = codeGenerator.generateCodeParent("tblCategory", "strCategCode", "Categ"); //refresh CategoryList refreshCategories(); this.CategoryName.Clear(); } else { MessageBox.Show("Input a Category name"); } }
//-----Mj method private void getUserandPass() { int count = dbConnect.Count("select count(*) from tblAdmin;"); if (count == 0) { dbConnect.Insert("insert into tbladmin values ('admin','user','pass','name','*****@*****.**','emailpass','message',false);"); MessageBox.Show("First application usage. Temporary values:\nName: name\nUser: user\nPassword: pass\nEmail: [email protected]\nEmail Password: emailpass\nMessage: message\nPlease change this values in the settings later."); } //to get username and pass string[] columns = { "strAdmUser", "strAdmPass" }; List <object>[] rs = dbConnect.Select("select * from tblAdmin where strAdmCode = 'admin';", columns); user = rs[0].ElementAt(0).ToString(); pass = rs[1].ElementAt(0).ToString(); }
private void button1_Click(object sender, EventArgs e) { string txtSectionCode = SectionCode.Text; string txtSectionName = SectionName.Text; if (SectionName.Text != "") { try { string txtSectionAdviser = getAdvisorCodeFromList(cmbAdvisorName.SelectedItem.ToString()); //search if existing if (!isExisting(txtSectionName, SectionList)) { dbConnect.Insert("insert into tblSection values('" + txtSectionCode + "','" + txtSectionName + "','" + txtSectionAdviser + "',false);"); this.SectionCode.Text = codeGenerator.generateCodeChild("tblSection", "strSectCode", getAdvisorCodeFromList(cmbAdvisorName.SelectedItem.ToString()), "Sec"); this.Close(); } SectionName.Clear(); } catch (Exception) { MessageBox.Show("No selected adviser"); } } else { MessageBox.Show("Input a Section name"); } try { this.cmbAdvisorName.SelectedIndex = 0; } catch (ArgumentOutOfRangeException) { MessageBox.Show("No Registered Adviser, Please register faculties first"); } }
private void BorrowIT_Click(object sender, EventArgs e) { string borHCode; string borDCode; try { string assetCode = this.ItemList.SelectedRows[0].Cells[0].Value.ToString(); string roomNum = RoomNumber.Text; string reason = textBox1.Text; if (roomNum != "" && reason != "") { if (canBorrow()) { if (transactionNowExist()) { borHCode = getTransactionCodeNow(); borDCode = codeGenerator.generateCodeChild("tblBorrowDetail", "strBorDCode", borHCode, "BorD"); DialogResult dialogResult = MessageBox.Show("Continue?", "Borrow?", MessageBoxButtons.YesNo); if (dialogResult == DialogResult.Yes) { //inserting borrower detail dbConnect.Insert("insert into tblBorrowDetail values ('" + borHCode + "','" + borDCode + "','" + reason + "','" + roomNum + "',null,null,'" + assetCode + "');"); RoomNumber.Text = ""; textBox1.Text = ""; MessageBox.Show("Borrowed Successfully!"); //Back button } else if (dialogResult == DialogResult.No) { } } else { borHCode = codeGenerator.generateCodeParent("tblBorrowHeader", "strBorHCode", "BorH"); borDCode = codeGenerator.generateCodeChild("tblBorrowDetail", "strBorDCode", borHCode, "BorD"); string dateNow = DateTime.Now.ToString("yyyy-MM-dd"); DialogResult dialogResult = MessageBox.Show("Continue?", "Borrow?", MessageBoxButtons.YesNo); if (dialogResult == DialogResult.Yes) { //inserting borrower header dbConnect.Insert("insert into tblBorrowHeader values ('" + borHCode + "','" + borrCode + "','" + dateNow + "',0);"); //inserting borrower detail dbConnect.Insert("insert into tblBorrowDetail values ('" + borHCode + "','" + borDCode + "','" + reason + "','" + roomNum + "',null,null,'" + assetCode + "');"); RoomNumber.Text = ""; textBox1.Text = ""; MessageBox.Show("Borrowed Successfully!"); } else if (dialogResult == DialogResult.No) { } } } //refresh ItemList refreshItemList(); } else { MessageBox.Show("Room number and reason are required."); } } catch { MessageBox.Show("No items available"); } }