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 binddata(string id) { Labelid.Text = Convert.ToString(id); BsolutionWebApp.Collecting object2 = DB.Collectings.Where(a => a.Collecting_Id.Equals(id)).SingleOrDefault(); TextCollectingNo.Text = object2.Collecting_No.ToString(); TextCollectingName.Text = object2.Collecting_Name.ToString(); TextBoxNote.Text = object2.Collecting_Note.ToString(); datepicker.Text = object2.Collecting_Date.ToString(); object2.IsDisable = false; ddChequeOrCash.SelectedValue = object2.BankorCash.ToString(); //DropDownListbankcashtype.SelectedValue = object2.BankCashtype_Id.ToString(); ddInvoice.SelectedValue = object2.Invoice_Id.ToString(); ddContact.SelectedValue = object2.Contact_Id.ToString(); ddOperationType.SelectedValue = object2.Operation_Type_Id.ToString(); Labelstatus.Text = "Collecting No=" + object2.Collecting_No + " -Date of Collecting" + object2.Collecting_Date; }
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.Cheque_Id = Int32.Parse(ddCheque.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 (object1.Invoice_Type_Id == 1) { bs.Addtransaction(2, "Invoice+", object1.Invoice_Id, object1.Invoice_Date, object1.Invoice_TotalCost, object1.Invoice_Price, object1.Invoice_Price - object1.Invoice_TotalCost, ""); } else if (object1.Invoice_Type_Id == 2) { bs.Addtransaction(4, "Invoice-", object1.Invoice_Id, object1.Invoice_Date, object1.Invoice_TotalCost, object1.Invoice_Price, object1.Invoice_Price - object1.Invoice_TotalCost, ""); } var serical = DB.Invoice_Serial_Collects.Where(a => a.Invoice_Serial_Collect_Collecting.Equals(DropDownListinvoicetype.SelectedValue)).SingleOrDefault(); serical.Invoice++; DB.Invoice_Serial_Collects.DefaultIfEmpty(serical); DB.SubmitChanges(); Labelstatus.Text = "Invoice No=" + object1.Invoice_No + " -Date of Invoice" + object1.Invoice_Date; }
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); }