private void btn_save_Click(object sender, EventArgs e) { errorProvider1.Clear(); if (txt_recno.Text.Trim() == "") { errorProvider1.SetError(txt_recno, "Reciept no cannot be a empty value. Press New button."); MessageBox.Show("Reciept no cannot be a empty value. Press New button.", Messaging.MessageCaption, MessageBoxButtons.OK, MessageBoxIcon.Error); return; } if (num_totalpay.Value <= 0) { errorProvider1.SetError(num_totalpay, "Reciept amount must grator than zero."); MessageBox.Show("Reciept amount must grator than zero.", Messaging.MessageCaption, MessageBoxButtons.OK, MessageBoxIcon.Error); return; } if (Details.Count <= 0) { errorProvider1.SetError(dgmain, "Reciept breakdown must be entred."); MessageBox.Show("Reciept breakdown must be entred.", Messaging.MessageCaption, MessageBoxButtons.OK, MessageBoxIcon.Error); return; } //if (txt_recivedfrom.Text.Trim() == "") //{ // MessageBox.Show("Recieved from cannot be a empty value.", Messaging.MessageCaption, MessageBoxButtons.OK, MessageBoxIcon.Error); // return; //} //if (txt_memo.Text.Trim() == "") //{ // MessageBox.Show("Memo cannot be a empty value.", Messaging.MessageCaption, MessageBoxButtons.OK, MessageBoxIcon.Error); // return; //} if (commonFunctions.ToDecimal(txt_remaining.Text) != 0) { errorProvider1.SetError(dgmain, "You must break the full amount."); MessageBox.Show("You must break the full amount.", Messaging.MessageCaption, MessageBoxButtons.OK, MessageBoxIcon.Error); return; } if (MessageBox.Show("Do you want to Save this record?", Messaging.MessageCaption, MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { try { ReceiptHed hed = new ReceiptHed(); hed.Amount = num_totalpay.Value; hed.CancelledDate = DateTime.Now; hed.CancelledReason = ""; hed.CancelledUser = 0; hed.CustomerId = commonFunctions.ToInt(cmb_customer.SelectedValue.ToString()); hed.Docno = txt_recno.Text; hed.Id = 0; hed.iscancelled = false; hed.IsGLUpdate = false; hed.IsProcessed = false; hed.Memo = txt_memo.Text; hed.processDate = DateTime.Now; hed.ProcessUserID = 0; hed.ReceiptDets = Details; hed.Recivedfrom = txt_recivedfrom.Text; hed.RecordDate = DateTime.Now; hed.ReferanceNo = 1; hed.Remarks = txt_Remarks.Text; hed.Status = 1; CustomeRepository.InsertReciept(hed); Details = null; dgmain.Rows.Clear(); documentno = CustomeRepository.GetSetDocumentNumber("SC002", 0, "RCT", 1); txt_recno.Text = documentno; LoadCustomerOutstandings(); } catch (Exception ex) { } } }