public static tblListHandoverReply InsertListHandoverReply(tblListHandoverReply handoverReply, List <tblHandover> listHandover, tblNumberGenerate numberGenerate) { var db = new dbTrainEntities(ConnectionController.GetConnection()); db.AddTotblNumberGenerates(numberGenerate); db.AddTotblListHandoverReplies(handoverReply); foreach (tblHandover handover in listHandover) { tblHandover obj = db.tblHandovers.Where(g => g.ID == handover.ID).FirstOrDefault(); if (obj != null) { obj.tblListHandoverReply = handoverReply; } } int result = db.SaveChanges(); if (result > 0) { return(handoverReply); } else { return(null); } }
private void grdHandover_CellDoubleClick(object sender, DataGridViewCellEventArgs e) { try { if (this.grdHandover.SelectedRows.Count > 0) { int selectedIndex = grdHandover.SelectedRows[0].Index; // gets the RowID from the first column in the grid var ID = Int64.Parse(grdHandover[0, selectedIndex].Value.ToString()); tblListHandoverReply reply = HandoverReplyFactory.FindByID(ID); if (reply == null) { MessageBox.Show("Bảng kê này không còn tồn tại trong Cơ Sở Dữ Liệu. Bạn hãy kiểm tra lại", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } else { FrmAddListHandoverReply form = new FrmAddListHandoverReply(this, _userInfo, reply, 1); form.MdiParent = this.MdiParent; form.Show(); } } else { MessageBox.Show("Bạn cần chọn một bản ghi để cập nhật", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning); } } catch (Exception ex) { } }
public FrmAddListHandoverReply(FrmListHandoverReply listReply, UserInfo userInfo, tblListHandoverReply tblListHandoverReply, short mode = (short)0) { InitializeComponent(); _userInfo = userInfo; _mode = mode; _listReplyForm = listReply; _listHanover = new List <tblHandover>(); _tblListHandoverReply = tblListHandoverReply; }
private void btnAddNew_Click(object sender, EventArgs e) { var dr = MessageBox.Show(ConstantInfo.CONFIRM_ADD_NEW, "Confirm", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (dr != DialogResult.Yes) { return; } if (!ValidateAddNew()) { return; } tblListHandoverReply hanoverReply = new tblListHandoverReply { ListReplyNumber = txtNumberHandoverReply.Text.Trim(), ListReplyDate = dtpHandoverReplyDate.Value, ReportFromDate = dtpFrom.Value, ReportToDate = dtpTo.Value, CustomsCodeReceiver = ddlCustomsName.SelectedValue.ToString(), ReplyStatusGoods = txtStatusGood.Text.Trim(), Note = txtNote.Text.Trim(), }; var resultHanoverReply = HandoverReplyFactory.InsertListHandoverReply(hanoverReply, _listHanover, _NumberGenerate); if (resultHanoverReply != null) { _tblListHandoverReply = resultHanoverReply; if (cbPrint.Checked == true) { MessageBox.Show("Thêm mới bảng kê hồi báo thành công. Bạn hãy tắt hộp thoại này để xem bản in"); print(); Reset(); } else { MessageBox.Show("Thêm mới bảng kê hồi báo thành công!"); Reset(); } } else { MessageBox.Show("Thêm mới bảng kê hồi báo không thành công!"); } if (_listReplyForm != null) { _listReplyForm.search(); } }
private void btnDelete_Click(object sender, EventArgs e) { try { if (this.grdHandover.SelectedRows.Count > 0) { DialogResult result = MessageBox.Show("Bạn thự sự muốn xóa bảng kê đã chọn?", "Cảnh báo!", MessageBoxButtons.YesNo); if (result == DialogResult.Yes) { int selectedIndex = grdHandover.SelectedRows[0].Index; // gets the RowID from the first column in the grid var ID = Int64.Parse(grdHandover[0, selectedIndex].Value.ToString()); tblListHandoverReply reply = HandoverReplyFactory.FindByID(ID); if (reply == null) { MessageBox.Show("Bảng kê này không còn tồn tại trong Cơ Sở Dữ Liệu. Bạn hãy kiểm tra lại", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } if (HandoverReplyFactory.Delete(reply.ID) > 0) { search(); MessageBox.Show("Xóa bảng kê thành công", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { search(); MessageBox.Show("Xóa bảng kê không thành công", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error); } } else { return; } } else { MessageBox.Show("Bạn cần chọn một bản ghi để xóa", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning); } } catch (Exception ex) { if (GlobalInfo.IsDebug) { MessageBox.Show(ex.ToString()); } } }
private bool ValidateAddNew() { bool valid = techlinkErrorProvider1.Validate(this); if (valid == true) { tblListHandoverReply reply = HandoverReplyFactory.FindByNumber(txtNumberHandoverReply.Text.Trim()); if (reply != null) { MessageBox.Show("Số bảng kê này đã tồn tại, xin chọn số mới"); return(false); } } return(valid); }
public static int UpdateListHandoverReply(tblListHandoverReply handoverReply, List <tblHandover> listHandover) { //update all related Handover RemoveListReplyIDFromHandover(handoverReply.ID); //update ListHandoverReply var db = new dbTrainEntities(ConnectionController.GetConnection()); tblListHandoverReply objUpdate = db.tblListHandoverReplies.Where(g => g.ID == handoverReply.ID).FirstOrDefault(); if (objUpdate != null) { try { objUpdate.ListReplyNumber = handoverReply.ListReplyNumber; objUpdate.ListReplyDate = handoverReply.ListReplyDate; objUpdate.ReportFromDate = handoverReply.ReportFromDate; objUpdate.ReportToDate = handoverReply.ReportToDate; objUpdate.CustomsCodeReceiver = handoverReply.CustomsCodeReceiver; objUpdate.ReplyStatusGoods = handoverReply.ReplyStatusGoods; objUpdate.Note = handoverReply.Note; //db.SaveChanges(); //db.Dispose(); //db = new dbTrainEntities(ConnectionController.GetConnection()); foreach (tblHandover handover in listHandover) { tblHandover obj = db.tblHandovers.Where(g => g.ID == handover.ID).FirstOrDefault(); if (obj != null) { obj.tblListHandoverReply = objUpdate; } } return(db.SaveChanges()); } catch (Exception ex) { return(0); } } return(0); }
private void print() { try { long replyId = _tblListHandoverReply.ID; tblListHandoverReply handoverReply = HandoverReplyFactory.FindByID(replyId); if (handoverReply == null) { MessageBox.Show("Không kết nối được với CSDL hoặc Bảng kê hồi báo này không còn tồn tại. Xin kiểm tra lại "); return; } var report = new ReportListHanoverReply(); var txtNumber = (TextObject)report.Section1.ReportObjects["txtNumber"]; var txtReplyDate = (TextObject)report.Section1.ReportObjects["txtReplyDate"]; var txtReceiverCustomsName = (TextObject)report.Section1.ReportObjects["txtReceiverCustomsName"]; var txtSummary = (TextObject)report.Section1.ReportObjects["txtSummary"]; var txtGoodsStatus = (TextObject)report.Section4.ReportObjects["txtGoodsStatus"]; var txtNote = (TextObject)report.Section4.ReportObjects["txtNote"]; txtNumber.Text = "Số: " + handoverReply.ListReplyNumber; txtReplyDate.Text = "Lạng Sơn, ngày " + handoverReply.ListReplyDate.GetValueOrDefault().Day + " tháng " + handoverReply.ListReplyDate.GetValueOrDefault().Month + " năm " + handoverReply.ListReplyDate.GetValueOrDefault().Year; txtReceiverCustomsName.Text = "Kính gửi: " + CustomsFacory.FindByCode(handoverReply.CustomsCodeReceiver).CustomsName; String fromDate = handoverReply.ReportFromDate.GetValueOrDefault().ToString("dd/MM/yyyy"); String toDate = handoverReply.ReportToDate.GetValueOrDefault().ToString("dd/MM/yyyy"); txtSummary.Text = " " + "Chi cục Hải quan ga ĐSQT Đồng đăng đã nhận được hàng và Biên bản bàn giao hàng nhập khẩu của chi cục từ ngày " + fromDate + " đến ngày " + toDate; txtGoodsStatus.Text = " " + "Tình trạng hàng hóa: " + handoverReply.ReplyStatusGoods; txtNote.Text = " " + handoverReply.Note; //fill table BBBG DataSet1 dataset = new DataSet1(); DataTable dt = dataset.tblHandover; if (handoverReply != null && handoverReply.tblHandovers.IsLoaded == false) { handoverReply.tblHandovers.Load(); } List <tblHandover> listHandover = handoverReply.tblHandovers.ToList(); foreach (tblHandover obj in listHandover) { if (obj.IsDeleted.GetValueOrDefault() != true) { dt.Rows.Add(obj.ID, obj.NumberHandover, obj.DateHandover, obj.CodeStation, obj.CodeStationFromTo, obj.StatusGoods, obj.StatusVehicle, obj.CreatedDate, obj.CreatedBy, obj.ModifiedDate, obj.ModifiedBy, obj.NumberReply, obj.DateReply, obj.NoteReply, obj.IsDeleted, obj.IsReplied, obj.Note, obj.Type, obj.ReplyStatusGoods, null); } } report.SetDataSource(dataset); FrmPreviewReport frmReport = new FrmPreviewReport(report); frmReport.MdiParent = this.MdiParent; frmReport.Show(); } catch (Exception ex) { } }