public void ddlVendorbind() { try { List <tbl_party> cd = context.tbl_party.Where(x => x.status == true && x.company_id == companyId && x.party_type == "Vendor").ToList(); ddlVendor.DataTextField = "party_name"; ddlVendor.DataValueField = "party_id"; ddlVendor.DataSource = cd; ddlVendor.DataBind(); ddlVendor.Items.Insert(0, new ListItem("--Select Vendor--", "0")); } catch (Exception ex) { ErrorLog.saveerror(ex); //Do Logging } }
protected void btnCancel_Click(object sender, EventArgs e) { try { //lblcheckDoubleError.Text = String.Empty; //btnSave.Visible = true; //btnUpdate.Visible = false; //divalert.Visible = false; //CLR(); ViewState["gridrow"] = null; // hde.Value = string.Empty; } catch (Exception ex) { ErrorLog.saveerror(ex); } }
protected void btnYes_Click(object sender, EventArgs e) { try { int rowindex = Convert.ToInt32(ViewState["rowIndex"]); context.sp_DeleteCategory(companyId, rowindex, branchId); loadDataTable(); divalert.Visible = true; lblAlert.Text = "Category Deleted "; } catch (Exception ex) { ErrorLog.saveerror(ex); //Do Logging } }
public void UpdateIsLogin(int userid) { try { context.tbl_User.FirstOrDefault(); var userdata = context.tbl_User.SingleOrDefault(u => u.user_id == userid); if (userdata != null) { userdata.Islogin = false; context.SaveChanges(); } } catch (Exception ex) { ErrorLog.saveerror(ex); } }
protected void Page_Load(object sender, EventArgs e) { try { SessionValue(); if (!IsPostBack) { PageLoad(); } } catch (Exception ex) { ErrorLog.saveerror(ex); //Do Logging } }
public void getdate() { try { //ef code awais var finicialyear = context.tbl_financialyear.Where(f => f.company_id == companyId && f.status == true).SingleOrDefault(); hd1.Value = finicialyear.start_date; hd2.Value = finicialyear.end_date; CalendarExtender1.StartDate = Convert.ToDateTime(finicialyear.start_date); CalendarExtender1.EndDate = DateTime.Today; } catch (Exception ex) { ErrorLog.saveerror(ex); } }
protected void Page_Load(object sender, EventArgs e) { try { companyId = Convert.ToInt32(HttpContext.Current.Session["company_id"]); branchId = Convert.ToInt32(HttpContext.Current.Session["branch_id"]); if (!IsPostBack) { loadDataTable(); } } catch (Exception ex) { ErrorLog.saveerror(ex); //Do Logging } }
protected void txtGivenAmt_TextChanged(object sender, System.EventArgs e) { try { decimal remainingBalance = Convert.ToDecimal(lblGrandTotal.Text) - Convert.ToDecimal(lblGivenAmnt.Text); //if (remainingBalance < 0) //{ // btnGetRefund.Visible = true; // txtBalanceAmnt.Text = (remainingBalance + Convert.ToDecimal(txtPaidAmnt.Text)).ToString(); //} //else if (txtPaidAmnt.Text == "0" || string.IsNullOrEmpty(txtPaidAmnt.Text)) //{ // btnGetRefund.Visible = false; // txtBalanceAmnt.Text = remainingBalance.ToString(); // return; //} //else //{ // txtBalanceAmnt.Text = (remainingBalance - Convert.ToDecimal(txtPaidAmnt.Text)).ToString(); //} decimal paidAmnt = Convert.ToDecimal(txtPaidAmnt.Text); if (remainingBalance < paidAmnt) { txtPaidAmnt.Text = remainingBalance.ToString(); txtBalanceAmnt.Text = "0"; } else if (paidAmnt != 0) { txtBalanceAmnt.Text = (remainingBalance - paidAmnt).ToString(); //decimal c = Convert.ToDecimal(lblGrandTotal.Text)-(remainingBalance + Convert.ToDecimal(txtPaidAmnt.Text)); //txtBalanceAmnt.Text = c.ToString(); } else { ClientScript.RegisterStartupScript(this.GetType(), "Pop", "openalert('Paid amount should be greator then zero');", true); } UpdatePanel2.Update(); } catch (Exception ex) { ErrorLog.saveerror(ex); } }
private void savecode() { try { if (hd.Value != "true") { lblcheckDoubleError.Text = String.Empty; tbl_rack rack = new tbl_rack(); rack.company_id = companyId; rack.branch_id = branchId; rack.godown_id = Int32.Parse(ddlGodownName.SelectedValue); rack.rack_name = txtRackName.Text; rack.created_by = User_id; rack.created_date = DateTime.Today; rack.status = true; rack.modified_by = ""; rack.modified_date = null; ////Shakeeb ////rd.Insert(rd); //Entity Framework Saving Awais context.tbl_rack.Add(rack); context.SaveChanges(); loadDataTable(); divalert.Visible = true; lblAlert.Text = "Rack Saved Successfully"; clr(); //lblError.Text = string.Empty; } else { divalert.Visible = false; lblcheckDoubleError.ForeColor = System.Drawing.Color.Red; lblcheckDoubleError.Text = "This Rack name already Exists"; return; } } catch (Exception ex) { ErrorLog.saveerror(ex); //Do Logging } }
private void savedlogic() { string User_id = Convert.ToString(Session["UserID"]); try { if (CheckDouble(txtGodownName.Text) == "false") { lblcheckDoubleError.Text = String.Empty; tbl_godown g = new tbl_godown(); g.company_id = companyId; g.branch_id = branchId; g.godown_name = txtGodownName.Text; g.godown_address = txtGodownAddress.Text; g.contact_no = txtContactNo.Text; g.contact_person = txtContactPerson.Text; //g.created_by = "admin"; g.created_by = User_id; g.created_date = DateTime.Today; g.status = true; g.modified_by = ""; g.modified_date = null; ////Shakeeb ////g.AddGodown(g); //Entity Framework Saving Awais context.tbl_godown.Add(g); context.SaveChanges(); clr(); divalert.Visible = true; lblAlert.Text = "Godown Saved Successfully"; } else { divalert.Visible = false; lblcheckDoubleError.ForeColor = System.Drawing.Color.Red; lblcheckDoubleError.Text = "This Godown name already Exists"; return; } } catch (Exception ex) { ErrorLog.saveerror(ex); //Do Logging } }
protected void btnYes_Click(object sender, EventArgs e) { try { int rowIndex = Convert.ToInt32(ViewState["rowIndex"]); context.sp_DeleteProduct(companyId, rowIndex); divalert.Visible = true; lblAlert.Text = "Product Deleted Successfully "; // clr(); loadDataTable(); } catch (Exception ex) { ErrorLog.saveerror(ex); //Do Logging } }
//protected void btnUpdate_Click(object sender, EventArgs e) //{ // updatecode(); //} protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e) { try { if (e.CommandName == "DeleteRow") { ViewState["rowIndex"] = Convert.ToInt32(e.CommandArgument); ClientScript.RegisterStartupScript(this.GetType(), "Pop", "openModal();", true); divalert.Visible = false; } } catch (Exception ex) { ErrorLog.saveerror(ex); //Do Logging } }
protected void btnYes_Click(object sender, EventArgs e) { try { ////Shakeeb ////p.Delete(p); context.sp_DeleteUser(companyId, Convert.ToInt32(ViewState["unit_id"]), Convert.ToInt32(ViewState["user_id"]), branchId); divalert.Visible = true; lblAlert.Text = "User Deleted Successfully "; clr(); } catch (Exception ex) { ErrorLog.saveerror(ex); //Do Logging } }
public void GetsaleDetails() { try { var sale = context.tbl_sale.Where(w => w.InvoiceNumber == txtSearchBox.Text && w.company_id == companyId && w.branch_id == branchId).FirstOrDefault(); if (sale == null) { ClientScript.RegisterStartupScript(this.GetType(), "Pop", "openalert('Invoice does not exist, Please enter valid Invoice Number.','True');", true); return; } hdnSaleId.Value = sale.sale_id.ToString(); sale_Id = sale.sale_id; } catch (Exception ex) { ErrorLog.saveerror(ex); } }
private void loadDataTable() { try { GridView1.DataSource = context.sp_SelectParty(companyId, branchId); GridView1.DataBind(); } catch (Exception ex) { ErrorLog.saveerror(ex); } finally { //con.Close(); //con.Dispose(); } }
protected void btnCloseMode_Click(object sender, EventArgs e) { try { ddlcategorybind(); ddlgodownbind(); ddlrackbind(Convert.ToInt32(ddlGodown.SelectedValue)); ddltaxbind(); ddlunitbind(); ScriptManager.RegisterStartupScript(this, GetType(), "Close Modal Popup", "Closepopup();", true); UpdatePanel1.Update(); } catch (Exception ex) { ErrorLog.saveerror(ex); //Do Logging } }
protected void Page_Load(object sender, EventArgs e) { try { SessionValue(); if (!IsPostBack) { loadDataTable(); txtExpenseName.Focus(); } } catch (Exception ex) { ErrorLog.saveerror(ex); //Do Logging } }
protected void btnYes_Click(object sender, EventArgs e) { try { int c_id = Convert.ToInt32(Session["company_id"]); int b_id = Convert.ToInt32(Session["branch_id"]); int rowIndex = Convert.ToInt32(ViewState["unit_id"]); context.sp_DeleteParty(c_id, b_id, rowIndex); divalert.Visible = true; lblAlert.Text = "Party Deleted Successfully "; CLR(); } catch (Exception ex) { ErrorLog.saveerror(ex); //Do Logging } }
protected void ddlBatch_SelectedIndexChanged(object sender, EventArgs e) { try { lblcheckDoubleError.Text = string.Empty; int productId = Convert.ToInt32(ddlproduct.SelectedValue); int batchId = Convert.ToInt32(ddlBatch.SelectedValue); var actualPurchaseTaxAndPrice = context.tbl_ActualPurchaseTaxAndPrice.Where(p => p.product_id == productId && p.batch_id == batchId).FirstOrDefault(); txtprice.Text = Convert.ToString(actualPurchaseTaxAndPrice.sale_price); txtTaxpercentage.Text = actualPurchaseTaxAndPrice.tax_percent.ToString(); UpdatePanel1.Update(); } catch (Exception ex) { ErrorLog.saveerror(ex); //Do Logging } }
public bool ValidateQuantity(int productId, int batchId) { bool isfail = false; try { if (!btnUpdate.Visible) { for (int i = 0; i <= gvpurchasedetails.Rows.Count - 1; i++) { int pId = Convert.ToInt32(gvpurchasedetails.Rows[i].Cells[2].Text); decimal qty = Convert.ToDecimal(gvpurchasedetails.Rows[i].Cells[5].Text); int bId = Convert.ToInt32(gvpurchasedetails.Rows[i].Cells[4].Text); if (pId == productId && batchId == bId) { isfail = true; lblcheckDoubleError.Visible = true; lblcheckDoubleError.Text = "Already product and batch added, Please select different product and batch or update existing product."; return(isfail); } } } decimal salePrice = Convert.ToDecimal(txtsalesprice.Text); decimal purchasePrice = Convert.ToDecimal(txtprice.Text); decimal tax = Convert.ToDecimal(txtTaxpercentage.Text); var isProductExsits = context.tbl_ActualPurchaseTaxAndPrice.Where(w => w.product_id == productId && w.batch_id == batchId).FirstOrDefault(); if (isProductExsits != null) { // var samePriceExists = context.tbl_ActualPurchaseTaxAndPrice.Where(w => w.product_id == productId && w.batch_id == batchId && w.sale_price== salePrice && w.purchase_rate==purchasePrice && w.tax_percent== tax).Any(); if (isProductExsits.sale_price != salePrice || isProductExsits.purchase_rate != purchasePrice || isProductExsits.tax_percent != tax) { isfail = true; lblcheckDoubleError.Visible = true; lblcheckDoubleError.Text = "Please change batch, As per configuration Purchase Price, Sale Price Or Tax has been changed."; return(isfail); } } } catch (Exception ex) { ErrorLog.saveerror(ex); } return(isfail); }
protected void btnAdd_Click(object sender, EventArgs e) { try { int c_id = Convert.ToInt32(Session["company_id"]); string vendor = ddlVendor.SelectedItem.Text.Trim(); string SON = txtSONo.Text.Trim(); string date = txtdate.Text.Trim(); string pname = ddlproduct.SelectedItem.Text.Trim(); string quantity = txtquantity.Text.Trim(); string price = txtprice.Text.Trim(); string discount = txtdiscount.Text.Trim(); int p_id = Convert.ToInt32(ddlproduct.SelectedValue); Tax_percent t = new Tax_percent(); t.company_id = c_id; t.product_id = p_id; t.All(t); int tax_id = t.tax_id; int unit_id = t.unit_id; string unit_name = t.unit_name; string tax_percentage = t.tax_percentage; int batch_id = t.batch_id; ViewState["b_id"] = batch_id; string batch_name = t.batch_name; int product_id = Convert.ToInt32(ddlproduct.SelectedValue); decimal SubTotal = Convert.ToInt32(txtquantity.Text) * Convert.ToInt32(txtprice.Text); decimal a = SubTotal / 100; decimal discountamt = a * decimal.Parse(discount); decimal tax_amount = a * decimal.Parse(tax_percentage); DataTable dt = (DataTable)Session["table"]; dt.Rows.Add(1, p_id, batch_id, unit_id, tax_id, SubTotal, discountamt, tax_amount, price, quantity, pname, unit_name, batch_name, tax_percentage); Session["table"] = dt; gvSalesdetails.DataSource = dt; gvSalesdetails.DataBind(); clr(); txtBalanceAmt.Enabled = true; txtGivenAmt.Enabled = true; calculation(SubTotal, tax_amount, discountamt); } catch (Exception ex) { ErrorLog.saveerror(ex); } }
protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e) { try { GridViewRow grv = ((GridViewRow)((LinkButton)e.CommandSource).NamingContainer); var id = e.CommandArgument; if (e.CommandName == "Order") { Response.Write(String.Format("<script>window.open('{0}','_blank')</script>", ResolveUrl(string.Format("~/Reports/ReportViewer.aspx?Id={0}&ReportName={1}", id, "PurchaseReport")))); // Response.Write(String.Format("<script>window.open('{0}','_blank')</script>", ResolveUrl(string.Format("~/Reports/PurchaseSaleReturnReport.aspx?Id={0}&ReportName={1}", id, "PurchaseReport")))); } else if (e.CommandName == "Invoice") { Response.Write(String.Format("<script>window.open('{0}','_blank')</script>", ResolveUrl(string.Format("~/Reports/ReportViewer.aspx?Id={0}&ReportName={1}", id, "CombinePurchaseAndReturnReport")))); //.Write(String.Format("<script>window.open('{0}','_blank')</script>", ResolveUrl(string.Format("~/Reports/CombineReport.aspx?Id={0}&ReportName={1}", id, "CombinePurchaseAndReturnReport")))); } else if (e.CommandName == "Return") { Response.Write(String.Format("<script>window.open('{0}','_blank')</script>", ResolveUrl(string.Format("~/Reports/ReportViewer.aspx?Id={0}&ReportName={1}", id, "PurchaseReturnReport")))); // Response.Write(String.Format("<script>window.open('{0}','_blank')</script>", ResolveUrl(string.Format("~/Reports/PurchaseSaleReturnReport.aspx?Id={0}&ReportName={1}", id, "PurchaseReturnReport")))); } else if (e.CommandName == "PurchaseTransationHistory") { Response.Write(String.Format("<script>window.open('{0}','_blank')</script>", ResolveUrl(string.Format("~/Reports/ReportViewer.aspx?Id={0}&ReportName={1}", id, "PurchaseTransationHistory")))); // Response.Write(String.Format("<script>window.open('{0}','_blank')</script>", ResolveUrl(string.Format("~/Reports/PurchaseSaleReturnReport.aspx?Id={0}&ReportName={1}", id, "PurchaseTransationHistory")))); } else if (e.CommandName == "ViewORPayBalance") { bool enablePayBalance = false; if (grv.Cells[5].Text != "0.00") { enablePayBalance = true; } Response.Redirect(string.Format("~/Purchases/ViewORPayBalancePurchase.aspx?Id={0}&ViewOrPayBalance={1}", id, enablePayBalance)); } } catch (Exception ex) { ErrorLog.saveerror(ex); //Do Logging } }
public bool uploadFile(FileUpload _fileUpload, string _path, string _fileName) { bool returnedMsg = false; try { if (_fileUpload.HasFile) { _fileName = Path.GetFileName(_fileUpload.PostedFile.FileName); _fileUpload.PostedFile.SaveAs(Server.MapPath(_path) + _fileName); returnedMsg = true; } } catch (Exception ex) { ErrorLog.saveerror(ex); } return(returnedMsg); }
protected void grvlist_SelectedIndexChanged(object sender, EventArgs e) { try { GridViewRow row = grvlist.SelectedRow; int rack_id = Convert.ToInt32(grvlist.DataKeys[row.RowIndex].Value); //int taxId = GridView1.SelectedIndex; txtName.Text = row.Cells[0].Text; //ddlGodownName.SelectedValue = row.Cells[2].Text; btnSave.Visible = false; btnUpdate.Visible = true; } catch (Exception ex) { ErrorLog.saveerror(ex); //Do Logging } }
protected void btnAdd_Click(object sender, EventArgs e) { int purchaseId = Convert.ToInt32(hdnPurchaseId.Value); //lblcheckDoubleError.Text = string.Empty; int productId = Convert.ToInt32(ddlproduct.SelectedValue); decimal enteredQuantity = Convert.ToDecimal(txtquantity.Text); try { //Get Original price, Tax and discount happened during Purchase var productDetails = context.sp_GetPurchaseDetailsById(purchaseId).ToList(); if (productDetails != null) { var oneproductDetail = productDetails.Where(w => w.product_id == productId); if (!Convert.ToBoolean(ValidateQuantity(enteredQuantity, productId, purchaseId)[0])) { decimal subTotal = Convert.ToDecimal(txtquantity.Text) * Convert.ToDecimal(oneproductDetail.FirstOrDefault().purchase_rate); decimal a = subTotal / 100; decimal discount_percent = (Convert.ToDecimal(oneproductDetail.FirstOrDefault().dicount_amt) * 100) / Convert.ToDecimal(oneproductDetail.FirstOrDefault().amount); decimal discountamt = a * Convert.ToDecimal(discount_percent.ToString("0.##")); decimal tax_amount = a * Convert.ToDecimal(oneproductDetail.FirstOrDefault().tax_percentage); clr(); calculation(subTotal, tax_amount, discountamt); txtPaidAmt.Enabled = true; DataTable tbl = (DataTable)ViewState["Details"]; tbl.Rows.Add(oneproductDetail.FirstOrDefault().purchasedetails_id, productId, oneproductDetail.FirstOrDefault().batch_id, oneproductDetail.FirstOrDefault().unit_id, oneproductDetail.FirstOrDefault().tax_id, subTotal, discountamt, tax_amount, oneproductDetail.FirstOrDefault().purchase_rate, enteredQuantity, oneproductDetail.FirstOrDefault().product_name, oneproductDetail.FirstOrDefault().unit_name, oneproductDetail.FirstOrDefault().batch_name, oneproductDetail.FirstOrDefault().tax_percentage); ViewState["Details"] = tbl; this.BindGrid(); ddlproduct.Items.FindByValue(productId.ToString()).Enabled = false; } } } catch (Exception ex) { ErrorLog.saveerror(ex); } }
protected void ddlproduct_SelectedIndexChanged(object sender, System.EventArgs e) { try { lblcheckDoubleError.Text = string.Empty; int productId = Convert.ToInt32(ddlproduct.SelectedValue); //var product = context.tbl_ActualPurchaseTaxAndPrice.Join(context.tbl_batch .Where(p => p.product_id == productId && p.batch_id==).Select(s=>new { s.batch_id,s.}); //txtprice.Text = Convert.ToString(product.sale_price); //int data = helper.GetStockQuantity(companyId, productId); //Session["quant"] = data; batchbind(productId); UpdatePanel1.Update(); } catch (Exception ex) { ErrorLog.saveerror(ex); //Do Logging } }
protected void Page_Load(object sender, EventArgs e) { try { //txtdate.Text = DateTime.Now.ToString("mm/dd/yyyy"); SessionValue(); if (!IsPostBack) { if (ViewState["Details"] == null) { DataTable dataTable = new DataTable(); dataTable.Columns.Add("Vendore"); dataTable.Columns.Add("Batch"); dataTable.Columns.Add("Product_id"); dataTable.Columns.Add("SON"); dataTable.Columns.Add("Date"); dataTable.Columns.Add("Product"); dataTable.Columns.Add("Quantity"); dataTable.Columns.Add("Price"); dataTable.Columns.Add("Discount"); dataTable.Columns.Add("Discount Amount"); dataTable.Columns.Add("Tax"); dataTable.Columns.Add("Tax Amount"); dataTable.Columns.Add("Sub Total"); dataTable.Columns.Add("batch_id"); ViewState["Details"] = dataTable; } txtdate.Text = DateTime.Now.ToString(); this.BindGrid(); ddlCustomerbind(); ddlproductbind(); ddlpaymentmodebind(); getdate(); txtSONo.Text = Common.GenerateInvoicenumber(companyId, branchId, Constants.Sale); ClearAll(); } } catch (Exception ex) { ErrorLog.saveerror(ex); } }
public void companyname() { tbl_company r = new tbl_company(); var company_id = Convert.ToInt32(Session["company_id"]); r = context.tbl_company.Where(w => w.company_id == company_id).SingleOrDefault(); try { if (Session["LoginuserName"] != null) { lblusername.Text = Session["LoginuserName"].ToString(); } if (r.logo != null) { if (File.Exists(Server.MapPath(r.logo))) { imglogo.ImageUrl = r.logo; } else { imglogo.Visible = false; lblIms.Visible = true; } } else { imglogo.Visible = false; lblIms.Visible = true; } } catch (Exception ex) { ErrorLog.saveerror(ex); } finally { con.Close(); con.Dispose(); } //lblHeading.Text= }
protected void Page_Load(object sender, EventArgs e) { try { User_id = Convert.ToString(Session["UserID"]); companyId = Convert.ToInt32(Session["company_id"]); branchId = Convert.ToInt32(Session["branch_id"]); if (!IsPostBack) { statebind(); txtPartyName.Focus(); } } catch (Exception ex) { ErrorLog.saveerror(ex); //Do Logging } }
public void getalldetials() { try { var set = context.tbl_setting.Where(w => w.company_id == companyId).FirstOrDefault(); ddlCurrency.SelectedValue = set.currency_id.ToString(); if (set.Enable_Invoice_Tax == true) { rbinvoicetax.Checked = true; } else { rbproducttax.Checked = true; } if (set.InvoiceTemplateName == "PurchaseSaleReturnReport1.rdlc") { rbPurchaseSaleReturnReport1.Checked = true; } else if (set.InvoiceTemplateName == "PurchaseSaleReturnReport2.rdlc") { rbPurchaseSaleReturnReport2.Checked = true; } else { rbPurchaseSaleReturnReport3.Checked = true; } if (set.PaperSize == "A4") { rbA4.Checked = true; } else { rbA5.Checked = true; } chbprintaddress.Checked = Convert.ToBoolean(set.Print_address); chbPrintTin.Checked = Convert.ToBoolean(set.Print_Tin_on_Invoice); } catch (Exception ex) { ErrorLog.saveerror(ex); } }