//To add data to the Invoice Table public bool InsertInvoiceRec(InvoiceDetailsEntity objInvoice, out int PKid) { objCommand.Parameters.Clear(); bool ii = false; try { objCommand.CommandText = "sp_InsertInvoiceRecord"; objCommand.CommandType = CommandType.StoredProcedure; objCommand.Parameters.Add("@invoiceId", SqlDbType.VarChar).Value = objInvoice.InvoiceNo; objCommand.Parameters.Add("@invoiceDate", SqlDbType.DateTime).Value = objInvoice.InvoiceDate; objCommand.Parameters.Add("@clientName", SqlDbType.VarChar).Value = objInvoice.ClientName; objCommand.Parameters.Add("@clientAddress", SqlDbType.VarChar).Value = objInvoice.ClientAddress; objCommand.Parameters.Add("@emailAddress", SqlDbType.VarChar).Value = objInvoice.EmailAddress; objCommand.Parameters.Add("@NoOfEmails", SqlDbType.Int).Value = objInvoice.NoOfEmails; objCommand.Parameters.Add("@discountAmount", SqlDbType.Decimal).Value = objInvoice.DiscountAmount; objCommand.Parameters.Add("@taxPercentage", SqlDbType.Decimal).Value = objInvoice.TaxPercentage; objCommand.Parameters.Add("@taxAmount", SqlDbType.Decimal).Value = objInvoice.TaxAmount; objCommand.Parameters.Add("@priceRate", SqlDbType.Decimal).Value = objInvoice.PriceRate; objCommand.Parameters.Add("@subAmount", SqlDbType.Decimal).Value = objInvoice.SubAmount; objCommand.Parameters.Add("@totalAmount", SqlDbType.Decimal).Value = objInvoice.TotalAmount; objCommand.Parameters.Add("@note", SqlDbType.VarChar).Value = objInvoice.Note; objCommand.Parameters.Add("@status", SqlDbType.VarChar).Value = objInvoice.Status; objCommand.Parameters.Add("@startDate", SqlDbType.DateTime).Value = objInvoice.StartDate; objCommand.Parameters.Add("@endDate", SqlDbType.DateTime).Value = objInvoice.EndDate; objCommand.Parameters.Add("@description", SqlDbType.VarChar).Value = objInvoice.Descripation; objCommand.Parameters.Add("@OutPKid", SqlDbType.Int).Direction = ParameterDirection.Output; DLConfig = new ConfigSettings(Globals.DBConnString, objCommand, DataProviderType.Sql); ii = DLCommand.ExecuteNonQuery(DLConfig); PKid = Convert.ToInt32(objCommand.Parameters["@OutPKid"].Value); } catch (Exception) { throw; } return ii; }
public bool InsertInvoiceRec(InvoiceDetailsEntity objInvoice,out int PKid) { return adminInvoice.InsertInvoiceRec(objInvoice, out PKid); }
protected void lbtnSaveExit_Click(object sender, EventArgs e) { try { if (Convert.ToDouble(lblgrandtotal.Text) <= 0.0 && hdGTotal.Value == "0")//'hdGTotal' is used to where ever change the amount in discount and tax% at that time we are store the value in hidden variable. ScriptManager.RegisterStartupScript(Page, Page.GetType(), "Success", "alert('Grand Total Amount should be Grater than zero!!')", true); else if (Convert.ToDouble(txtdiscount.Text) > Convert.ToDouble(lbltotal.Text)) ScriptManager.RegisterStartupScript(Page, Page.GetType(), "Success", "alert('Total Amount should be Grater than DsicountAmount or Equal!!')", true); else if (Convert.ToDateTime(txtStartDate.Text) > Convert.ToDateTime(txtEndDate.Text)) ScriptManager.RegisterStartupScript(Page, Page.GetType(), "Success", "alert('StartDate should be Grater than EndDate!!')", true); else { List<InvoiceDetailsEntity> ListobjInvoice = new List<InvoiceDetailsEntity>(); InvoiceDetailsEntity objInvoice = new InvoiceDetailsEntity(); objInvoice.InvoiceNo = "INV-" + txtInvoiceNo.Text.ToString(); objInvoice.InvoiceDate = Convert.ToDateTime(txtInvoiceDate.Text.ToString()); objInvoice.ClientName = ddlClients.Text.ToString(); objInvoice.ClientAddress = txtClientInfo.Text.ToString().Trim(); objInvoice.EmailAddress = clientEmail.ToString(); objInvoice.NoOfEmails = Convert.ToInt32(lblnoofemailsent.Text.ToString()); if (txtdiscount.Text != "") objInvoice.DiscountAmount = Convert.ToDouble(txtdiscount.Text.ToString()); if (txtTax.Text != "") objInvoice.TaxPercentage = Convert.ToDouble(txtTax.Text.ToString()); if (hdTaxAmt.Value != "0") objInvoice.TaxAmount = Convert.ToDouble(hdTaxAmt.Value); else objInvoice.TaxAmount = Convert.ToDouble(lblamttax.Text.ToString()); objInvoice.PriceRate = Convert.ToDouble(lblprice.Text.ToString()); objInvoice.SubAmount = Convert.ToDouble(lblamount.Text.ToString()); if (hdGTotal.Value != "0") objInvoice.TotalAmount = Convert.ToDouble(hdGTotal.Value); else objInvoice.TotalAmount = Convert.ToDouble(lblgrandtotal.Text.ToString()); objInvoice.Note = txtnote.Text.ToString(); objInvoice.Status = "Outstanding"; objInvoice.StartDate = Convert.ToDateTime(txtStartDate.Text); objInvoice.EndDate = Convert.ToDateTime(txtEndDate.Text); objInvoice.Descripation = txtdesc.Text.ToString(); int PKid = 0; bool insertStatus = objBlAdminInvoice.InsertInvoiceRec(objInvoice, out PKid); if (tblDesc.Rows.Count > 0 && tblAmount.Rows.Count > 0) { for (int i = 1; i <= tblDesc.Rows.Count && i <= tblAmount.Rows.Count; i++) { InvoiceDetailsEntity objInvoiceDesc = new InvoiceDetailsEntity(); TextBox txtDescDynamic = (TextBox)this.FindControlRecursive(this, "txtDesc" + i.ToString()); TextBox txtAmtDynamic = (TextBox)this.FindControlRecursive(this, "txtAmt" + i.ToString()); if (txtDescDynamic != null && txtAmtDynamic != null && ((System.Web.UI.WebControls.WebControl)(tblDesc.Rows[i - 1])).Style.Value != "display:none;" && ((System.Web.UI.WebControls.WebControl)(tblAmount.Rows[i-1])).Style.Value != "display:none;") { objInvoiceDesc.InvoiceId = PKid; objInvoiceDesc.InvoiceNo = "INV-" + txtInvoiceNo.Text.ToString(); objInvoiceDesc.ClientName = ddlClients.Text.ToString(); if (txtDescDynamic.Text != "") objInvoiceDesc.Descripation = txtDescDynamic.Text; if (txtAmtDynamic.Text != "") objInvoiceDesc.SubAmount = Convert.ToDouble(txtAmtDynamic.Text); ListobjInvoice.Add(objInvoiceDesc); } } } objBlAdminInvoice.InsertInvoiceDescription(ListobjInvoice); if (insertStatus) Response.Redirect("~/adminpages/AdminBManageInvoice.aspx?ddlID=" + ddlClients.SelectedIndex); } } catch (Exception ex) { throw ex; } }