private void btnSave_MouseUp(object sender, MouseButtonEventArgs e) { if (string.IsNullOrEmpty(txtClass.Text) || string.IsNullOrEmpty(txtTitle.Text) || string.IsNullOrEmpty(txtType.Text) || dtpDate.SelectedDate == null || dtpSubmission.SelectedDate == null) { return; } else if ((string.IsNullOrEmpty(txtSubBy.Text) && string.IsNullOrEmpty(txtSurBra.Text)) || (string.IsNullOrEmpty(txtSubTo.Text) && string.IsNullOrEmpty(txtSudBra.Text))) { return; } Details det = new Details() { Datee = dtpDate.SelectedDate.Value.Date, Title = txtTitle.Text, Clas = txtClass.Text, Type = txtType.Text, State = cmbState.SelectionBoxItem.ToString(), Author = txtAuthor.Text, Status = cmbStatus.SelectionBoxItem.ToString(), DocNumber = txtDocNo.Text, RepliedNumber = txtReplied.Text, Description = txtDesc.Text, SubDatee = dtpSubmission.SelectedDate.Value.Date, SubmittedBy = txtSubBy.Text, SubmittedTo = txtSubTo.Text, SubmittedBranch = txtSudBra.Text, SubmitterBranch = txtSurBra.Text, RoomNo = txtRoomNo.Text, ShelfNo = txtShelfNo.Text, FileNo = txtFileNo.Text, Borrower = txtBorrower.Text, DigitalCopy = DigitalCopy, }; OleDbConnection conn = new OleDbConnection("Provider = Microsoft.ACE.OLEDB.12.0; Data Source = " + System.IO.Path.GetDirectoryName(System.Diagnostics.Process.GetCurrentProcess().MainModule.FileName) + @"\document.accdb;Persist Security Info=False;"); if (task.CheckDocNo(det) == true) { if (string.IsNullOrEmpty(det.RepliedNumber) == true || task.CheckReply(det) == true) { try { conn.Open(); OleDbCommand kaydet1 = new OleDbCommand("INSERT INTO Details([Datee],[Title],[Clas],[Type],[State],[Author],[Status],[DocNumber],[RepliedNumber],[Description],[DigitalCopy]) VALUES (@Datee,@Title,@Class,@Type,@State,@Author,@Status,@DocNumber,@RepliedNumber,@Description,@DigitalCopy)", conn); OleDbCommand kaydet2 = new OleDbCommand("INSERT INTO Submission ([SubDatee],[SubmittedBy],[SubmittedTo],[SubmitterBranch],[SubmittedBranch]) VALUES (@SubDatee,@SubmittedBy,@SubmittedTo,@SubmitterBranch,@SubmittedBranch)", conn); OleDbCommand kaydet3 = new OleDbCommand("INSERT INTO Location ([RoomNo],[ShelfNo],[FileNo],[Borrower]) VALUES (@RoomNo,@ShelfNo,@FileNo,@Borrower)", conn); kaydet1.Parameters.AddWithValue("Datee", OleDbType.Date).Value = det.Datee; kaydet1.Parameters.AddWithValue("Title", OleDbType.VarChar).Value = det.Title; kaydet1.Parameters.AddWithValue("Clas", OleDbType.VarChar).Value = det.Clas; kaydet1.Parameters.AddWithValue("Type", OleDbType.VarChar).Value = det.Type; kaydet1.Parameters.AddWithValue("State", OleDbType.VarChar).Value = det.State; kaydet1.Parameters.AddWithValue("Author", OleDbType.VarChar).Value = det.Author; kaydet1.Parameters.AddWithValue("Status", OleDbType.VarChar).Value = det.Status; kaydet1.Parameters.AddWithValue("DocNumber", OleDbType.VarChar).Value = det.DocNumber; kaydet1.Parameters.AddWithValue("RepliedNumber", OleDbType.VarChar).Value = det.RepliedNumber; kaydet1.Parameters.AddWithValue("Description", OleDbType.LongVarChar).Value = det.Description; kaydet1.Parameters.AddWithValue("DigitalCopy", OleDbType.VarChar).Value = det.DigitalCopy; kaydet2.Parameters.AddWithValue("Datee", det.SubDatee); kaydet2.Parameters.AddWithValue("SubmittedBy", det.SubmittedBy); kaydet2.Parameters.AddWithValue("SubmittedTo", det.SubmittedTo); kaydet2.Parameters.AddWithValue("SubmitterBranch", det.SubmitterBranch); kaydet2.Parameters.AddWithValue("SubmittedBranch", det.SubmittedBranch); kaydet3.Parameters.AddWithValue("RoomNo", det.RoomNo); kaydet3.Parameters.AddWithValue("ShelfNo", det.ShelfNo); kaydet3.Parameters.AddWithValue("FileNo", det.FileNo); kaydet3.Parameters.AddWithValue("Borrower", det.Borrower); kaydet1.ExecuteNonQuery(); kaydet2.ExecuteNonQuery(); kaydet3.ExecuteNonQuery(); conn.Close(); Close(); } catch (Exception ex) { conn.Close(); MessageBox.Show(ex.Message, "Error", MessageBoxButton.OK, MessageBoxImage.Error); } } else { MessageBox.Show("There is no document number like written in 'Reply Document Number'", "Reply Document Number Doesn't Exist", MessageBoxButton.OK, MessageBoxImage.Information); imgReply.Source = new BitmapImage(new Uri(@"\lib\docno.png", UriKind.Relative)); } } else { if (string.IsNullOrEmpty(det.DocNumber)) { MessageBox.Show("This Document Already Saved", "Dublication Document Information", MessageBoxButton.OK, MessageBoxImage.Information); } else { MessageBox.Show("The Document Number* Already Saved", "Dublication Document Number", MessageBoxButton.OK, MessageBoxImage.Information); imgDocNumber.Source = new BitmapImage(new Uri(@"\lib\docno.png", UriKind.Relative)); } } }
private void btnModify_MouseUp(object sender, MouseButtonEventArgs e) { if (string.IsNullOrEmpty(txtClass.Text) || string.IsNullOrEmpty(txtTitle.Text) || string.IsNullOrEmpty(txtType.Text) || dtpDate.SelectedDate == null || dtpSubmission.SelectedDate == null) { return; } else if ((string.IsNullOrEmpty(txtSubBy.Text) && string.IsNullOrEmpty(txtSurBra.Text)) || (string.IsNullOrEmpty(txtSubTo.Text) && string.IsNullOrEmpty(txtSudBra.Text))) { return; } Details det = new Details() { Datee = dtpDate.SelectedDate.Value.Date, Title = txtTitle.Text, Clas = txtClass.Text, Type = txtType.Text, State = cmbState.SelectionBoxItem.ToString(), Author = txtAuthor.Text, Status = cmbStatus.SelectionBoxItem.ToString(), DocNumber = txtDocNo.Text, RepliedNumber = txtReplied.Text, Description = txtDesc.Text, SubDatee = dtpSubmission.SelectedDate.Value.Date, SubmittedBy = txtSubBy.Text, SubmittedTo = txtSubTo.Text, SubmitterBranch = txtSurBra.Text, SubmittedBranch = txtSudBra.Text, RoomNo = txtRoomNo.Text, ShelfNo = txtShelfNo.Text, FileNo = txtFileNo.Text, Borrower = txtBorrower.Text, DigitalCopy = selected.DigitalCopy, }; OleDbConnection conn = new OleDbConnection("Provider = Microsoft.ACE.OLEDB.12.0; Data Source = " + System.IO.Path.GetDirectoryName(System.Diagnostics.Process.GetCurrentProcess().MainModule.FileName) + @"\document.accdb;Persist Security Info=False;"); Details selectedd = task.AllDetails(selected.Id); if (task.EditCheckDocNo(det, selectedd) == true) { if (string.IsNullOrEmpty(det.RepliedNumber) == true || task.CheckReply(det) == true) { try { conn.Open(); OleDbCommand update1 = new OleDbCommand("UPDATE Details SET Datee=@Datee, Title=@Title, Clas=@Clas, Type=@Type, State=@State, Author=@Author, Status=@Status, DocNumber=@DocNumber, RepliedNumber=@RepliedNumber, Description=@Description, DigitalCopy=@DigitalCopy WHERE Id=@Id", conn); OleDbCommand update2 = new OleDbCommand("UPDATE Submission SET SubDatee=@SubDatee, SubmittedBy=@SubmittedBy, SubmittedTo=@SubmittedTo, SubmitterBranch=@SubmitterBranch, SubmittedBranch=@SubmittedBranch WHERE Id=@Id", conn); OleDbCommand update3 = new OleDbCommand("UPDATE Location SET RoomNo=@RoomNo, ShelfNo=@ShelfNo, FileNo=@FileNo, Borrower=@Borrower WHERE Id=@Id", conn); update1.Parameters.AddWithValue("Datee", OleDbType.Date).Value = det.Datee; update1.Parameters.AddWithValue("Title", OleDbType.VarChar).Value = det.Title; update1.Parameters.AddWithValue("Clas", OleDbType.VarChar).Value = det.Clas; update1.Parameters.AddWithValue("Type", OleDbType.VarChar).Value = det.Type; update1.Parameters.AddWithValue("State", OleDbType.VarChar).Value = det.State; update1.Parameters.AddWithValue("Author", OleDbType.VarChar).Value = det.Author;; update1.Parameters.AddWithValue("Status", OleDbType.VarChar).Value = det.Status; update1.Parameters.AddWithValue("DocNumber", OleDbType.VarChar).Value = det.DocNumber; update1.Parameters.AddWithValue("RepliedNumber", OleDbType.VarChar).Value = det.RepliedNumber; update1.Parameters.AddWithValue("Description", OleDbType.LongVarChar).Value = det.Description; update1.Parameters.AddWithValue("DigitalCopy", OleDbType.VarChar).Value = det.DigitalCopy; update1.Parameters.AddWithValue("Id", selected.Id); update2.Parameters.AddWithValue("Datee", det.SubDatee); update2.Parameters.AddWithValue("SubmittedBy", det.SubmittedBy); update2.Parameters.AddWithValue("SubmittedTo", det.SubmittedTo); update2.Parameters.AddWithValue("SubmitterBranch", det.SubmitterBranch); update2.Parameters.AddWithValue("SubmittedBranch", det.SubmittedBranch); update2.Parameters.AddWithValue("Id", selected.Id); update3.Parameters.AddWithValue("RoomNo", det.RoomNo); update3.Parameters.AddWithValue("ShelfNo", det.ShelfNo); update3.Parameters.AddWithValue("FileNo", det.FileNo); update3.Parameters.AddWithValue("Borrower", det.Borrower); update3.Parameters.AddWithValue("Id", selected.Id); update1.ExecuteNonQuery(); update2.ExecuteNonQuery(); update3.ExecuteNonQuery(); conn.Close(); Close(); } catch (Exception ex) { conn.Close(); MessageBox.Show(ex.Message, "Error", MessageBoxButton.OK, MessageBoxImage.Error); } } else { MessageBox.Show("There is no document number like written in 'Reply Document Number'", "Reply Document Number Doesn't Exist", MessageBoxButton.OK, MessageBoxImage.Information); imgReply.Source = new BitmapImage(new Uri(@"\lib\docno.png", UriKind.Relative)); } } else { if (string.IsNullOrEmpty(det.DocNumber)) { MessageBox.Show("This Document Already Saved", "Dublication Document Information", MessageBoxButton.OK, MessageBoxImage.Information); } else { MessageBox.Show("The Document Number* Already Saved", "Dublication Document Number", MessageBoxButton.OK, MessageBoxImage.Information); imgDocNumber.Source = new BitmapImage(new Uri(@"\lib\docno.png", UriKind.Relative)); } } }