private void btnSave_Click(object sender, EventArgs e) { slot.InStatus = cmbInOrOut.SelectedIndex == 0 ? false : true; slot.OccupaidStatus = cmbOccupaid.SelectedIndex == 0 ? false : true; slot.FK_CustomerId = entTransactions.FK_Customer; slot.FK_StaffId = cmbStaff.SelectedValue.ToInt32(); if (ORMForSDF.UpdateToDatabaseObj(slot, "Slot", "Id", slot.Id.toInt32(), Properties.Settings.Default.Connection)) { string status = string.Empty; if (cmbOccupaid.SelectedIndex == 0) { status = "Alotment Removed"; } else { if (cmbInOrOut.SelectedIndex == 0) { status = "Outed"; } else { status = "In"; } } entTransactions.FK_Staff = cmbStaff.SelectedValue.ToInt32(); entTransactions.Date = DateTime.Now; entTransactions.Status = status; if (ORMForSDF.InsertToDatabaseObj(entTransactions, "Transactions", Properties.Settings.Default.Connection)) { this.DialogResult = System.Windows.Forms.DialogResult.OK; this.Close(); } } this.DialogResult = DialogResult.OK; this.Close(); }
private void btnSave_Click(object sender, EventArgs e) { if (txtName.Text == string.Empty || txtPanNo.Text == string.Empty) { Messages.WarningMessage(); return; } var customer = new Customer { Id = iCustomerId, Name = txtName.Text, PanNumber = txtPanNo.Text, Company = txtCompany.Text, Careof = txtCareof.Text, Password = txtPassword.Text, Fk_SlotId = cmbSlot.SelectedValue.ToInt32(), Fk_StaffId = cmbStaff.SelectedValue.ToInt32(), isExpaired = cmbExpaired.SelectedIndex == 0 ? false : true }; if (iCustomerId == null || !db.Customers.Any(x => x.Id == iCustomerId)) { if (ORMForSDF.InsertToDatabaseObj(customer, "Customer", Properties.Settings.Default.Connection)) { customer = db.Customers.FirstOrDefault(x => x.Name == txtName.Text); Slot slot = db.Slots.FirstOrDefault(x => x.Id == cmbSlot.SelectedValue.ToInt32()); slot.OccupaidStatus = true; slot.InStatus = true; slot.FK_CustomerId = customer.Id; slot.FK_StaffId = cmbStaff.SelectedValue.ToInt32(); ORMForSDF.UpdateToDatabaseObj(slot, "Slot", "Id", slot.Id.toInt32(), Properties.Settings.Default.Connection); var transaction = new Transactions { Id = null, FK_Customer = slot.FK_CustomerId, FK_Slot = slot.Id, FK_Staff = cmbStaff.SelectedValue.ToInt32(), Date = DateTime.Now.Date, Status = "Allotted", Remarks = "" }; if (ORMForSDF.InsertToDatabaseObj(transaction, "Transactions", Properties.Settings.Default.Connection)) { var trans = new Transactions { Id = null, FK_Customer = slot.FK_CustomerId, FK_Slot = slot.Id, FK_Staff = cmbStaff.SelectedValue.ToInt32(), Date = DateTime.Now.Date, Status = "In", Remarks = "" }; if (ORMForSDF.InsertToDatabaseObj(trans, "Transactions", Properties.Settings.Default.Connection)) { Messages.SavedMessage(); btnClear_Click(null, null); } } } } else { if (ORMForSDF.UpdateToDatabaseObj(customer, "Customer", "Id", iCustomerId.toInt32(), Properties.Settings.Default.Connection)) { Messages.UpdateMessage(); btnClear_Click(null, null); } } }
private void btnSave_Click(object sender, EventArgs e) { if (txtName.Text == string.Empty && slots.Count > 0) { Messages.ErrorMessage("Please fill the details."); return; } var box = new Box { Id = iBoxId, Name = txtName.Text, FK_StaffId = cmbStaff.SelectedValue.ToInt32(), CreatedOn = DateTime.Now.Date }; if (iBoxId == null) { if (ORMForSDF.InsertToDatabaseObj(box, "Box", Properties.Settings.Default.Connection)) { box = db.Boxes.FirstOrDefault(x => x.Name == txtName.Text); if (box.Id != null) { foreach (var item in slots) { item.FK_BoxId = box.Id.ToInt32(); } ORMForSDF.InsertToDatabase(slots.Cast <object>().ToList(), "Slot", Properties.Settings.Default.Connection); Messages.SavedMessage(); btnClear_Click(null, null); } } } else { if (ORMForSDF.UpdateToDatabaseObj(box, "Box", "Id", iBoxId.toInt32(), Properties.Settings.Default.Connection)) { if (iBoxId != null) { foreach (var item in slots) { item.FK_BoxId = iBoxId.ToInt32(); } ORMForSDF.UpdateDatabase(slots.Cast <object>().ToList(), oldSlots.Cast <object>().ToList(), "Slot", "Id", Properties.Settings.Default.Connection); Messages.UpdateMessage(); btnClear_Click(null, null); } } } }
private void btnSave_Click(object sender, EventArgs e) { if (txtName.Text == string.Empty) { Messages.ErrorMessage("Please fill the details."); return; } if (iStaffId == null || !db.Staffs.Any(x => x.Id == iStaffId)) { if (isFirstEntry) { if (ORMForSDF.InsertToDatabaseObj(new Staff { Id = null, Name = txtName.Text, Password = txtPassword.Text }, "Staff", Properties.Settings.Default.Connection)) { Login frm = new Login(); this.Hide(); frm.Show(); } } else { if (db.Staffs.FirstOrDefault(x => x.Id == User.iUserId).Name == "Admin") { if (ORMForSDF.InsertToDatabaseObj(new Staff { Id = null, Name = txtName.Text, Password = txtPassword.Text }, "Staff", Properties.Settings.Default.Connection)) { Messages.SavedMessage(); btnClear_Click(null, null); } } else { Messages.ErrorMessage("Only Admin have power to create new User."); } } } else { if (ORMForSDF.UpdateToDatabaseObj(new Staff { Id = iStaffId, Name = txtName.Text, Password = txtPassword.Text }, "Staff", "Id", iStaffId.toInt32(), Properties.Settings.Default.Connection)) { Messages.UpdateMessage(); btnClear_Click(null, null); } ; } }