private void TxtToMiti_Validating(object sender, System.ComponentModel.CancelEventArgs e) { if (_Tag == "" || ActiveControl == TxtToMiti) { return; } if (TxtToMiti.Text != " / /") { DateTime dt = Convert.ToDateTime(_objDate.GetDate(TxtToMiti.Text).Value.ToString()); TxtToDate.Text = dt.ToShortDateString(); } else { MessageBox.Show("Please enter valid miti.", "Mr. Solutions", MessageBoxButtons.OK, MessageBoxIcon.Error); TxtToMiti.Focus(); } }
private void BtnSave_Click(object sender, EventArgs e) { if (string.IsNullOrEmpty(TxtDescription.Text.Trim())) { MessageBox.Show("Description cannot be left blank.", "Mr Solution", MessageBoxButtons.OK, MessageBoxIcon.Information); TxtDescription.Focus(); return; } if (string.IsNullOrEmpty(TxtBodyLength.Text.Trim())) { MessageBox.Show("Bodylength Cannot Left Blank...!", "Mr Solution", MessageBoxButtons.OK, MessageBoxIcon.Information); TxtBodyLength.Focus(); return; } int.TryParse(TxtBodyLength.Text, out int _TxtBodyLengt); if (_TxtBodyLengt == 0) { MessageBox.Show("Please enter bodylength greater then 0.", "Mr Solution", MessageBoxButtons.OK, MessageBoxIcon.Information); TxtBodyLength.Focus(); return; } _objDocNumber.Model.Tag = _Tag; _objDocNumber.Model.DocId = this.DocId; if ((_Tag == "EDIT" || _Tag == "DELETE") && DocId == 0) { ClearFld(); return; } _objDocNumber.Model.DocId = this.DocId; _objDocNumber.Model.DocModule = TxtModule.Text; _objDocNumber.Model.DocDesc = TxtDescription.Text; if (ClsGlobal.DateType == "D") { _objDocNumber.Model.DocStartDate = Convert.ToDateTime(TxtStartDate.Text); _objDocNumber.Model.DocEndDate = Convert.ToDateTime(TxtEndDate.Text); _objDocNumber.Model.DocStartMiti = _objDateMiti.GetMiti(Convert.ToDateTime(TxtStartDate.Text)); _objDocNumber.Model.DocEndMiti = _objDateMiti.GetMiti(Convert.ToDateTime(TxtEndDate.Text)); } else { _objDocNumber.Model.DocStartDate = Convert.ToDateTime(_objDateMiti.GetDate(TxtStartDate.Text.ToString())); _objDocNumber.Model.DocEndDate = Convert.ToDateTime(_objDateMiti.GetDate(TxtEndDate.Text.ToString())); _objDocNumber.Model.DocStartMiti = TxtStartDate.Text; _objDocNumber.Model.DocEndMiti = TxtEndDate.Text; } _objDocNumber.Model.DocType = CmbNumberingType.Text.Trim(); _objDocNumber.Model.DocPrefix = TxtPrefix.Text; _objDocNumber.Model.DocSufix = TxtSuffix.Text; _objDocNumber.Model.DocBodyLength = Convert.ToInt32(TxtBodyLength.Text); _objDocNumber.Model.DocTotalLength = Convert.ToInt32(TxtTotalLength.Text); _objDocNumber.Model.DocIsNumericFill = ((ChkNumericFill.Checked == true) ? true : false); _objDocNumber.Model.DocFillCharacter = TxtFillCharacter.Text; // _objDocNumber.Model.BranchId = ((CmbBranch.Tag.ToString() == "0") ? 0 : Convert.ToInt32(CmbBranch.Tag.ToString())); // _objDocNumber.Model.CompanyUnitId = ((CmbCompanyUnit.Tag.ToString() == "0") ? 0 : Convert.ToInt32(CmbCompanyUnit.Tag.ToString())); _objDocNumber.Model.DocStartNo = Convert.ToInt32(TxtStartNo.Text); _objDocNumber.Model.DocCurrentNo = Convert.ToInt32(TxtCurrentNo.Text); _objDocNumber.Model.DocEndNo = Convert.ToInt32(TxtEndNo.Text); // _objDocNumber.Model.PrintDesignId = ((CmbPrintDesign.Tag.ToString() == "") ? 0 : Convert.ToInt32(CmbPrintDesign.Tag.ToString())); _objDocNumber.Model.EnterBy = ClsGlobal.LoginUserCode; _objDocNumber.Model.Gadget = "Desktop"; if (RbtnAuto.Checked == true) { _objDocNumber.Model.NumericalStyle = "Auto"; } else if (RbtnNumeric.Checked == true) { _objDocNumber.Model.NumericalStyle = "Numberic"; } else { _objDocNumber.Model.NumericalStyle = "AlfaNumeric"; } _objDocNumber.Model.Status = true; if (_Tag == "NEW") { if (ClsGlobal.ConfirmSave == 1) { var dialogResult = MessageBox.Show("Are you sure want to Save New Record..??", "Close Form", MessageBoxButtons.YesNo, MessageBoxIcon.Error); if (dialogResult == DialogResult.Yes) { result = _objDocNumber.SaveDocNumbering(); } else { return; } } else { result = _objDocNumber.SaveDocNumbering(); } } else { result = _objDocNumber.SaveDocNumbering(); } if (!string.IsNullOrEmpty(result)) { MessageBox.Show("Data submit successfully", "Mr Solution", MessageBoxButtons.OK, MessageBoxIcon.Information); ClearFld(); TxtDescription.Focus(); } else { MessageBox.Show("Error occured during data submit", "Mr Solution", MessageBoxButtons.OK, MessageBoxIcon.Information); } }