protected void insertdata() { BsolutionWebApp.Collecting object1 = new BsolutionWebApp.Collecting(); object1.Collecting_No = Int32.Parse(TextCollectingNo.Text); object1.Collecting_Name = TextCollectingName.Text; object1.Collecting_Note = TextBoxNote.Text; object1.Collecting_Date = Convert.ToDateTime(datepicker.Text); object1.IsDisable = false; //object1.BankCashtype_Id = Int32.Parse(DropDownListbankcashtype.SelectedValue); object1.BankorCash = int.Parse(ddChequeOrCash.SelectedValue); object1.Invoice_Id = Int32.Parse(ddInvoice.SelectedValue); object1.Contact_Id = Int32.Parse(ddContact.SelectedValue); object1.Operation_Type_Id = Int32.Parse(ddOperationType.SelectedValue); object1.Rectime = DateTime.Now; object1.User_Id = 0; DB.Collectings.InsertOnSubmit(object1); DB.SubmitChanges(); bsclass bs = new bsclass(); if (ddChequeOrCash.SelectedValue == "0") { bs.AddBank(object1.Collecting_Id, false, object1.Collecting_Amount, object1.Collecting_Date, Convert.ToInt32(DropDownListbankcashtype.SelectedValue), object1.Collecting_Note, "+", "", 0, 0, false); } else if (ddChequeOrCash.SelectedValue == "1") { bs.Addcash(object1.Collecting_Id, false, object1.Collecting_Amount, object1.Collecting_Date, Convert.ToInt32(DropDownListbankcashtype.SelectedValue), object1.Collecting_Note, "+", "", 0, 0, false); } Labelid.Text = object1.Collecting_Id.ToString(); }
protected void insertdata() { Labelstatus.Text = ""; bsclass bs = new bsclass(); decimal balance = 0; if (DropDownListbankcash.SelectedValue == "0") { balance = bs.checkblance(true, Convert.ToInt32(DropDownListbankcashtype.SelectedValue)); } else if (DropDownListbankcash.SelectedValue == "1") { balance = bs.checkblance(false, Convert.ToInt32(DropDownListbankcashtype.SelectedValue)); } if (balance >= Convert.ToDecimal(Convert.ToDouble(TextBoxunitcost.Text) * Convert.ToDouble(TextBoxquantity.Text))) { Expense newobject = new Expense(); newobject.Expenses_No = Convert.ToInt32(TextBoxExpensesNo.Text); newobject.Expenses_Cost = Convert.ToDouble(TextBoxunitcost.Text); newobject.Expenses_Date = Convert.ToDateTime(TextBoxdate.Text); newobject.Expenses_PersonInCharge = Convert.ToString(TextBoxfrom.Text); newobject.Expenses_Quantity = Convert.ToDouble(TextBoxquantity.Text); newobject.Expenses_Total = Convert.ToDouble(TextBoxunitcost.Text) * Convert.ToDouble(TextBoxquantity.Text); newobject.Expenses_Type_Id = Convert.ToInt32(DropDownListExpenseType.SelectedValue); newobject.Rectime = DateTime.Now; newobject.Expenses_Rectime = DateTime.Now; newobject.UserId = Convert.ToInt32(Session["userid"]); newobject.IsDisable = false; newobject.Expenses_From = DateTime.Now; newobject.Note = TextBoxNote.Text; DB.Expenses.InsertOnSubmit(newobject); DB.SubmitChanges(); if (DropDownListbankcash.SelectedValue == "0") { bs.AddBank(newobject.Expenses_Id, false, newobject.Expenses_Total, newobject.Expenses_Date, Convert.ToInt32(DropDownListbankcashtype.SelectedValue), newobject.Expenses_PersonInCharge, "-", "", 0, 0, false); } else if (DropDownListbankcash.SelectedValue == "1") { bs.Addcash(newobject.Expenses_Id, false, newobject.Expenses_Total, newobject.Expenses_Date, Convert.ToInt32(DropDownListbankcashtype.SelectedValue), newobject.Expenses_PersonInCharge, "-", "", 0, 0, false); } } else { Labelstatus.Text = "The Currenct Balance Doesn't allow this transaction Current Balance is :" + balance; } }
protected void inser() { BsolutionWebApp.Collecting object1 = null; if (Labelcollectingid.Text == "0") { Labelstatus.Text = ""; if (DropDownListInvoicetype.SelectedValue == "2") { bsclass bs = new bsclass(); decimal balance = 0; if (DropDownList1.SelectedValue == "0") { balance = bs.checkblance(true, Convert.ToInt32(DropDownListbankcashtype.SelectedValue)); } else if (DropDownList1.SelectedValue == "1") { balance = bs.checkblance(false, Convert.ToInt32(DropDownListbankcashtype.SelectedValue)); } if (balance < Convert.ToDecimal((TextBoxamount.Text))) { Labelstatus.Text = "The Currenct Balance Doesn't allow this transaction Current Balance is :" + balance; return; } } object1 = new BsolutionWebApp.Collecting(); object1.Collecting_No = Int32.Parse(TextBoxCollectingNo.Text); object1.Collecting_Name = TextBoxcollectingname.Text; object1.Collecting_Note = TextBoxNote.Text; object1.Collecting_Date = Convert.ToDateTime(TextBoxdate.Text); object1.IsDisable = false; object1.Collecting_Note = Convert.ToString(DropDownListbankcashtype.SelectedValue); if (RadioButtonBankOrCash.Checked == true) { object1.BankorCash = int.Parse(DropDownList1.SelectedValue); } object1.Invoice_Id = Int32.Parse(DropDownListInvoice.SelectedValue); object1.Collecting_Amount = Convert.ToDouble(TextBoxamount.Text); object1.Collecting_WhatsLeft = Convert.ToDouble(TextBoxleft.Text) - Convert.ToDouble(TextBoxamount.Text); object1.Operation_Type_Id = Int32.Parse(DropDownListInvoicetype.SelectedValue); object1.Rectime = DateTime.Now; object1.User_Id = 0; object1.Collecting_Rectime = DateTime.Now; object1.Log_Date = DateTime.Now; DB.Collectings.InsertOnSubmit(object1); DB.SubmitChanges(); var serial = DB.Invoice_Serial_Collects.Where(a => a.Invoice_Serial_Collect_Collecting.Equals(DropDownListInvoicetype.SelectedValue)).SingleOrDefault(); serial.Collecting = object1.Collecting_No; DB.Invoice_Serial_Collects.DefaultIfEmpty(serial); DB.SubmitChanges(); } else { object1 = DB.Collectings.Where(a => a.Collecting_Id.Equals(Labelcollectingid.Text)).SingleOrDefault(); Labelstatus.Text = ""; if (DropDownListInvoicetype.SelectedValue == "2") { bsclass bs = new bsclass(); decimal balance = 0; if (DropDownList1.SelectedValue == "0") { balance = bs.checkblance(true, Convert.ToInt32(DropDownListbankcashtype)); } else if (DropDownList1.SelectedValue == "1") { balance = bs.checkblance(false, Convert.ToInt32(DropDownListbankcashtype)); } if ((balance + Convert.ToDecimal(object1.Collecting_Amount)) < Convert.ToDecimal((TextBoxamount.Text))) { Labelstatus.Text = "The Currenct Balance Doesn't allow this transaction Current Balance is :" + balance; return; } } object1.Collecting_Name = TextBoxcollectingname.Text; object1.Collecting_Note = TextBoxNote.Text; object1.Collecting_Date = Convert.ToDateTime(TextBoxdate.Text); object1.IsDisable = false; object1.Collecting_Note = Convert.ToString(DropDownListbankcashtype.SelectedValue); if (RadioButtonBankOrCash.Checked == true) { object1.BankorCash = int.Parse(DropDownList1.SelectedValue); } object1.Collecting_Amount = Convert.ToDouble(TextBoxamount.Text); object1.Collecting_WhatsLeft = Convert.ToDouble(TextBoxleft.Text) - Convert.ToDouble(TextBoxamount.Text); object1.Operation_Type_Id = Int32.Parse(DropDownListInvoicetype.SelectedValue); object1.User_Id = 0; object1.Collecting_Rectime = DateTime.Now; object1.Log_Date = DateTime.Now; DB.Collectings.DefaultIfEmpty(object1); DB.SubmitChanges(); } if (RadioButtonBankOrCash.Checked == true) { bsclass bs = new bsclass(); if (DropDownList1.SelectedValue == "0") { if (DB.Banks.Where(a => a.Collecting_Id.Equals(object1.Collecting_Id)).Count() == 0) { if (DropDownListInvoicetype.SelectedValue == "1") { bs.AddBank(object1.Collecting_Id, true, object1.Collecting_Amount, object1.Collecting_Date, Convert.ToInt32(DropDownListbankcashtype.SelectedValue), "", "+", TextBoxNote.Text, object1.Collecting_Amount, 0, false); } else if (DropDownListInvoicetype.SelectedValue == "2") { bs.AddBank(object1.Collecting_Id, true, object1.Collecting_Amount, object1.Collecting_Date, Convert.ToInt32(DropDownListbankcashtype.SelectedValue), "", "-", TextBoxNote.Text, object1.Collecting_Amount, 0, false); } } else { if (DropDownListInvoicetype.SelectedValue == "1") { bs.editBank(object1.Collecting_Id, true, object1.Collecting_Amount, object1.Collecting_Date, Convert.ToInt32(DropDownListbankcashtype.SelectedValue), "", "+", TextBoxNote.Text, object1.Collecting_Amount, 0, false); } else if (DropDownListInvoicetype.SelectedValue == "2") { bs.editBank(object1.Collecting_Id, true, object1.Collecting_Amount, object1.Collecting_Date, Convert.ToInt32(DropDownListbankcashtype.SelectedValue), "", "-", TextBoxNote.Text, object1.Collecting_Amount, 0, false); } } } else if (DropDownList1.SelectedValue == "1") { if (DB.Cashes.Where(a => a.Collecting_Id.Equals(object1.Collecting_Id)).Count() == 0) { if (DropDownListInvoicetype.SelectedValue == "1") { bs.Addcash(object1.Collecting_Id, true, object1.Collecting_Amount, object1.Collecting_Date, Convert.ToInt32(DropDownListbankcashtype.SelectedValue), "", "+", TextBoxNote.Text, object1.Collecting_Amount, 0, false); } else if (DropDownListInvoicetype.SelectedValue == "2") { bs.Addcash(object1.Collecting_Id, true, object1.Collecting_Amount, object1.Collecting_Date, Convert.ToInt32(DropDownListbankcashtype.SelectedValue), "", "-", TextBoxNote.Text, object1.Collecting_Amount, 0, false); } } else { if (DropDownListInvoicetype.SelectedValue == "1") { bs.editcash(object1.Collecting_Id, true, object1.Collecting_Amount, object1.Collecting_Date, Convert.ToInt32(DropDownListbankcashtype.SelectedValue), "", "+", TextBoxNote.Text, object1.Collecting_Amount, 0, false); } else if (DropDownListInvoicetype.SelectedValue == "2") { bs.editcash(object1.Collecting_Id, true, object1.Collecting_Amount, object1.Collecting_Date, Convert.ToInt32(DropDownListbankcashtype.SelectedValue), "", "-", TextBoxNote.Text, object1.Collecting_Amount, 0, false); } } } } else if (RadioButtonCheque.Checked == true) { var cheque = DB.Cheques.Where(a => a.Collecting_Id.Equals(object1.Collecting_Id)); if (cheque.Count() == 0) { BsolutionWebApp.Cheque object2 = new BsolutionWebApp.Cheque(); object2.Cheque_No = Convert.ToString(TextBoxchequeno.Text); object2.Cheque_Bank_Name = TextBoxchequebankname.Text; object2.Cheque_Date = Convert.ToDateTime(TextBoxdate.Text); object2.IsDisable = false; object2.Cheque_Notes = TextBoxNote.Text; object2.Collecting_Id = object1.Collecting_Id; object2.RecTime = DateTime.Now; object2.PersonInCharge = ""; object2.Cheque_Notes = ""; DB.Cheques.InsertOnSubmit(object2); DB.SubmitChanges(); } else { var cheque2 = DB.Cheques.Where(a => a.Collecting_Id.Equals(object1.Collecting_Id)).SingleOrDefault(); cheque2.Cheque_No = Convert.ToString(TextBoxchequeno.Text); cheque2.Cheque_Bank_Name = TextBoxchequebankname.Text; cheque2.Cheque_Date = Convert.ToDateTime(TextBoxdate.Text); DB.Cheques.DefaultIfEmpty(cheque2); DB.SubmitChanges(); } } Labelcollectingid.Text = "0"; Response.Redirect("CollectingPageAdd?ID=" + Labelinvoiceid.Text); }