private void btnSubmit_Click(object sender, EventArgs e) { modelShift.UpdateBy = userid; modelShift.UpdateDate = DateTime.Now; modelShift.EndShift = DateTime.Now; var cashEnd = this.txtCashEnd.Text.Replace("$", ""); modelShift.CashEnd = double.Parse(cashEnd); MoneyFortmat Fomat = new MoneyFortmat(1); modelShift.CashEnd = Fomat.getFortMat(modelShift.CashEnd ?? 0); var safeDrop = this.txtSafeDrop.Text.Replace("$", ""); modelShift.SafeDrop = double.Parse(safeDrop); modelShift.SafeDrop = Fomat.getFortMat(modelShift.SafeDrop ?? 0); if (modelShift.CashEnd < modelShift.CashStart) { frmMessager frm = new frmMessager("Messenger", "Cash end isn't less than cash start. "); frmOpacity.ShowDialog(this, frm); } else { var result = ShiftService.UpdateDataShiftHistory(modelShift); var messenger = "Save data end shift fail."; if (result > 0) { AddDataPrinter(); GetListPrinter(); foreach (PrinterModel item in PrintData) { Header = item.Header; posPrinter.SetPrinterName(item.PrinterName); posPrinter.printDocument.PrintPage += printDocument_PrintPage; posPrinter.Print(); } UserLoginModel.ShiffID = 0; messenger = "Save data end shift successful."; this.DialogResult = System.Windows.Forms.DialogResult.OK; } frmMessager frm = new frmMessager("Messenger", messenger); frmOpacity.ShowDialog(this, frm); } }
private void btnCreate_Click(object sender, EventArgs e) { var model = new ShiftHistoryModel(); model.ShiftName = this.txtShiftName.Text ?? ""; model.StaffID = 0; var cbStaff = (KeyValueModel)this.cbStaff.SelectedItem; if (cbStaff != null) { model.StaffID = cbStaff.Key; } model.CashStart = 0; if (this.txtCashStart.Text != "") { model.CashStart = double.Parse(this.txtCashStart.Text); } MoneyFortmat Fomat = new MoneyFortmat(1); model.CashStart = Fomat.getFortMat(model.CashStart ?? 0); model.CreateBy = userid; var messenger = ""; if (model.ShiftName == "") { messenger = messenger + "Shift Name isn't empty. "; } if (model.StaffID == 0) { messenger = messenger + "Staff Name isn't empty. "; } if (model.CashStart == 0) { messenger = messenger + "Cash Start isn't empty. "; } if (messenger == "") { var result = ShiftService.InsertDataShiftHistory(model); messenger = "Save data new shift fail."; if (result > 0) { UserLoginModel.ShiffID = result; messenger = "Save data new shift successful."; this.DialogResult = System.Windows.Forms.DialogResult.OK; } frmMessager frm = new frmMessager("Messenger", messenger); frmOpacity.ShowDialog(this, frm); } else { frmMessager frm = new frmMessager("Messenger", messenger + "Please input data."); frmOpacity.ShowDialog(this, frm); } }