public string GetCustomerCreditFromName(string companyName) { customerManager objcustomer = new customerManager(); try { if (companyName != "") { objcustomer.contactName = Convert.ToString(companyName); objcustomer.companyName = Convert.ToString(companyName); string Credits = string.Empty; Credits = objcustomer.GetCustomerCreditFromName(); return(Credits); } else { return("fail"); } } catch (Exception ex) { throw ex; } finally { objcustomer = null; } }
protected void Page_Load(object sender, EventArgs e) { string querystring = Request.Url.AbsoluteUri; string[] strvalue = querystring.Split('.'); customerManager objcust = new customerManager(); int compneyid = 0; for (int i = 0; i < strvalue.Length; i++) { objcust.companyName = Convert.ToString(strvalue[i].Replace("http://", "")); compneyid = objcust.GetCompanyIdFromCompanyName(); if (compneyid > 0) { Response.Write("Company ID = " + compneyid); Response.End(); break; } Response.Write(querystring.Replace("http://", "")); Response.End(); //else //{ // Response.Write("testing 404."); // Response.End(); //} } }
public List <string> BindCustomerName(string companyName) { customerManager objCustomer = new customerManager(); objCustomer.companyName = Convert.ToString(companyName); List <string> MPN = new List <string>(); DataTable dt = new DataTable(); try { dt = objCustomer.BindCustomerName(); if (dt.Rows.Count > 0) { foreach (DataRow dr in dt.Rows) { MPN.Add(dr["companyName"].ToString()); } } else { MPN.Add("No record found"); } return(MPN); } catch (Exception ex) { throw ex; } finally { dt.Dispose(); objCustomer = null; } }
//handle delete event protected void imgbtnDelete_Click(object sender, EventArgs e) { customerManager objcust = new customerManager(); try { int con = 0; CheckBox chk = new CheckBox(); string ActImage = string.Empty; string ThumbImage = string.Empty; DataSet dsadmin = new DataSet(); for (int i = 0; i < gvAdmin.Rows.Count; i++) { chk = (CheckBox)(gvAdmin.Rows[i].FindControl("chkDelete")); if (chk.Checked == true) { con += 1; objcust.customerId = Convert.ToInt32(gvAdmin.DataKeys[gvAdmin.Rows[i].RowIndex].Value.ToString()); // objuser.DeleteAdminRightsItem(); objcust.DeleteItem(); //Menu delete logic goes here //if (System.IO.File.Exists(Server.MapPath("~") + "/admin/menu/" + objuser.adminid + ".htm")) //{ // System.IO.File.Delete(Server.MapPath("~") + "/admin/menu/" + objuser.adminid + ".htm"); //} } } Response.Redirect("viewcustomer.aspx?flag=delete&key=" + txtsearch.Text + " &pageSize=" + ddlpageSize.SelectedValue + ""); //Response.Redirect("viewinventory.aspx?flag=delete"); } catch (Exception ex) { throw ex; } finally { objcust = null; } }
// Use this for initialization void Start() { flag = 1; slider.maxValue = Random.Range(waitingPatienceRange.x, waitingPatienceRange.y); slider.value = slider.maxValue; parent = myParentCustomer.GetComponent <customerManager>(); }
protected void lnkStatus_click(object sender, EventArgs e) { customerManager objprod = new customerManager(); GridViewRow row = ((LinkButton)sender).Parent.Parent as GridViewRow; objprod.isActive = Convert.ToBoolean(Convert.ToInt32(((LinkButton)sender).CommandArgument) == 0 ? 1 : 0); objprod.customerId = Convert.ToInt32(gvAdmin.DataKeys[gvAdmin.Rows[row.RowIndex].RowIndex].Value.ToString()); objprod.UpdateStatus(); BindCustomer(); //trmsg.Visible = true; //lblmsgs.Text = "Admin Menu details are updated successfully"; }
public string UpdateCustomerCreditsLimits(string customerid, string Credits) { customerManager objcust = new customerManager(); if (customerid != "" && Credits != "") { objcust.creditLimit = Convert.ToString(Credits); objcust.customerId = Convert.ToInt32(customerid); objcust.UpdateCustomerCreditsLimits(); return("Credit limits update successfully."); } else { return("Fail"); } }
public List <string> SearchKeywordCustomer(string SearchKey) { customerManager objcust = new customerManager(); objcust.SearchKey = Convert.ToString(SearchKey); List <string> MPN = new List <string>(); DataTable dt = new DataTable(); dt = objcust.SearchKeywordCustomer(); if (dt.Rows.Count > 0) { foreach (DataRow dr in dt.Rows) { MPN.Add(Server.HtmlDecode(dr["SearchKey"].ToString())); } } else { MPN.Add("No record found"); } return(MPN); }
protected void lnkEdit_Click(object sender, EventArgs e) { customerManager objcust = new customerManager(); orderManager objorder = new orderManager(); DataTable dtcustomer = new DataTable(); try { if (Request.QueryString["customer"] != null) { objcust.customerId = Convert.ToInt32(Request.QueryString["customer"]); decimal CreditLimits = objcust.GetCustomerCreditFromID(); string reducePercent = ""; string GlobleDiscount = ""; dtcustomer = objcust.GetCustomerIdAndDiscountCreditByID(); if (dtcustomer.Rows.Count > 0) { GlobleDiscount = dtcustomer.Rows[0]["globleDiscountRate"].ToString(); reducePercent = dtcustomer.Rows[0]["reducePercent"].ToString(); } objorder.orderid = Convert.ToInt32(Request.QueryString["orderid"]); decimal TotalAmmount = objorder.GetSumOfItemPriceUsingOrderId(); if (Request.QueryString["chkid"].ToString() != System.Configuration.ConfigurationManager.AppSettings["PayTypeCredit"].ToString()) { if (Convert.ToDecimal(CreditLimits) > Convert.ToDecimal(lblTotalPayAmmount.Text.Replace("SAR", "").Trim())) { //string credits = creditLimits.ToString().Replace("SAR", "").Replace(".00", ""); objcust.creditLimit = Convert.ToString(Convert.ToInt32(CreditLimits) - Convert.ToInt32(TotalAmmount)); if (GlobleDiscount.Replace("%", "") == "0") { objcust.globleDiscountRate = "0"; } else { objcust.globleDiscountRate = Convert.ToString(Convert.ToInt32(GlobleDiscount.Replace("%", "")) - Convert.ToInt32(5)) + "%"; } objcust.UpdateCustomerCreditLimits(); //order paytype update objorder.payType = Convert.ToInt32(System.Configuration.ConfigurationManager.AppSettings["PayTypeCredit"]); objorder.updatePayType(); Response.Redirect("add_order.aspx?orderid=" + Request.QueryString["orderid"] + "&chkid" + Request.QueryString["chkid"] + "&customer=" + Request.QueryString["customer"]); } else { lblmsg.Visible = true; lblmsgs.Text = "Your credit limits is lower than total payment."; ScriptManager.RegisterStartupScript(this, GetType(), "InvokeButton", "invokeButtonClick();", true); } } // if cash on delivery if (Request.QueryString["chkid"].ToString() != System.Configuration.ConfigurationManager.AppSettings["PayTypeCase"].ToString()) { objcust.creditLimit = Convert.ToString(Convert.ToInt32(CreditLimits) + Convert.ToInt32(TotalAmmount)); objcust.globleDiscountRate = Convert.ToString(Convert.ToInt32(GlobleDiscount.Replace("%", "")) + Convert.ToInt32(5)) + "%"; objcust.UpdateCustomerCreditLimits(); //order paytype update objorder.payType = Convert.ToInt32(System.Configuration.ConfigurationManager.AppSettings["PayTypeCase"]); objorder.updatePayType(); Response.Redirect("add_order.aspx?orderid=" + Request.QueryString["orderid"] + "&chkid" + Request.QueryString["chkid"] + "&customer=" + Request.QueryString["customer"]); } } } catch (Exception ex) { throw; } finally { objorder = null; objcust = null; dtcustomer.Dispose(); } }
protected void btnConfirmOrder_Click(object sender, EventArgs e) { orderManager objorder = new orderManager(); //if (Session["OrderId"] != null) //{ if (Request.QueryString["orderid"] != null) { objorder.orderid = Convert.ToInt32(Request.QueryString["orderid"]); int Ammount = objorder.getTotalAmountFromOrderId(); if (Ammount != 0) { objorder.orderid = Convert.ToInt32(Request.QueryString["orderid"]); objorder.orderstatus = Convert.ToInt32(System.Configuration.ConfigurationManager.AppSettings["OrderRecieved"]); if (rbtCOD.Checked == true) { objorder.payType = Convert.ToInt32(System.Configuration.ConfigurationManager.AppSettings["PayTypeCase"]); } if (rbtCredit.Checked == true) { objorder.payType = Convert.ToInt32(System.Configuration.ConfigurationManager.AppSettings["PayTypeCredit"]); } objorder.UpdateOrderStatusByOrderId(); string strCustomerName = txtCustomer.Text.Trim(); int customer_id; string creditLimits = ""; string reducePercent = ""; string GlobleDiscount = ""; customerManager objcustomer = new customerManager(); DataTable dtcustomer = new DataTable(); objcustomer.contactName = Convert.ToString(strCustomerName); objcustomer.companyName = Convert.ToString(strCustomerName); try { customer_id = objcustomer.GetCustomerId(); if (rbtCredit.Checked == true) { dtcustomer = objcustomer.GetCustomerIdAndDiscountCredit(); if (dtcustomer.Rows.Count > 0) { customer_id = Convert.ToInt32(dtcustomer.Rows[0]["customerid"]); GlobleDiscount = dtcustomer.Rows[0]["globleDiscountRate"].ToString(); creditLimits = dtcustomer.Rows[0]["creditLimit"].ToString(); reducePercent = dtcustomer.Rows[0]["reducePercent"].ToString(); } decimal TotalAmmount = objorder.GetSumOfItemPriceUsingOrderId(); string credits = creditLimits.ToString().Replace("SAR", "").Replace(".00", ""); objcustomer.creditLimit = Convert.ToString(Convert.ToInt32(credits) - Convert.ToInt32(TotalAmmount)); objcustomer.customerId = Convert.ToInt32(customer_id); if (GlobleDiscount.Replace("%", "") == "0") { objcustomer.globleDiscountRate = "0"; } else { objcustomer.globleDiscountRate = Convert.ToString(Convert.ToInt32(GlobleDiscount.Replace("%", "")) - Convert.ToInt32(5)) + "%"; } objcustomer.UpdateCustomerCreditLimits(); } } catch (Exception c) { throw c; } finally { objcustomer = null; } SendMail(Convert.ToInt32(Request.QueryString["orderid"]), customer_id, Convert.ToInt32(System.Configuration.ConfigurationManager.AppSettings["EmailNotificationsOrderReceivedId"])); Session["cust_name"] = ""; //Response.Redirect("vieworder.aspx?orderid=" + Request.QueryString["orderid"]); Response.Redirect("vieworder.aspx"); } else { //Response.Write("<script>alert('There are no items avaliable in order');</script>"); lblerrMsg.Text = "There are no items avaliable in order."; } } }
protected void btnAddProOrder_Click(object sender, EventArgs e) { Session["msg"] = ""; string strCustomerName = txtCustomer.Text.Trim(); int customer_id = 0; string creditLimits = ""; string reducePercent = ""; string GlobleDiscount = ""; int order_id = 0; bool ordFlag = false; //decimal discount = Convert.ToDecimal(0.0); decimal netPayment = Convert.ToDecimal(0.0); customerManager objcustomer = new customerManager(); DataTable dtcustomer = new DataTable(); objcustomer.contactName = Convert.ToString(strCustomerName); objcustomer.companyName = Convert.ToString(strCustomerName); try { //customer_id = objcustomer.GetCustomerId(); dtcustomer = objcustomer.GetCustomerIdAndDiscountCredit(); if (dtcustomer.Rows.Count > 0) { customer_id = Convert.ToInt32(dtcustomer.Rows[0]["customerid"]); GlobleDiscount = dtcustomer.Rows[0]["globleDiscountRate"].ToString(); creditLimits = dtcustomer.Rows[0]["creditLimit"].ToString(); reducePercent = dtcustomer.Rows[0]["reducePercent"].ToString(); } } catch (Exception c) { throw c; } finally { objcustomer = null; } foreach (GridViewRow row in GVOrder.Rows) { if (row.RowType == DataControlRowType.DataRow) { bool isChecked = row.Cells[0].Controls.OfType <CheckBox>().FirstOrDefault().Checked; if (isChecked) { string lblProdutId = row.Cells[0].Controls.OfType <Label>().FirstOrDefault().Text; string lblPrice = row.Cells[4].Controls.OfType <Label>().FirstOrDefault().Text; string TxtQty = row.Cells[6].Controls.OfType <TextBox>().FirstOrDefault().Text; string lblproName = row.Cells[3].Controls.OfType <Label>().FirstOrDefault().Text; string lblCost = row.Cells[2].Controls.OfType <Label>().FirstOrDefault().Text; orderManager objorder = new orderManager(); try { objorder.productid = Convert.ToInt32(lblProdutId); int Inventory = objorder.GetInventoryByProductid(); if (Inventory >= Convert.ToInt32(TxtQty)) { objorder.customerid = Convert.ToInt32(customer_id); //objorder.orderstatus = Convert.ToInt32(1); if (ordFlag == false && Request.QueryString["orderid"] == null && Convert.ToInt32(Request.QueryString["orderid"]) == 0) { if (rbtCOD.Checked == true) { objorder.payType = Convert.ToInt32(System.Configuration.ConfigurationManager.AppSettings["PayTypeCase"]); } if (rbtCredit.Checked == true) { objorder.payType = Convert.ToInt32(System.Configuration.ConfigurationManager.AppSettings["PayTypeCredit"]); } objorder.contactName = Convert.ToString(strCustomerName); order_id = objorder.InsertOrder(); // insert into order table ordFlag = true; } else { if (Request.QueryString["orderid"] != null && Convert.ToInt32(Request.QueryString["orderid"]) != 0) { order_id = Convert.ToInt32(Request.QueryString["orderid"]); ordFlag = true; } } objorder.productid = Convert.ToInt32(lblProdutId); objorder.productName = Server.HtmlEncode(Convert.ToString(lblproName)); objorder.globleDiscountRate = Convert.ToInt32(GlobleDiscount.Replace("%", "")); objorder.costPrice = Convert.ToDecimal(lblCost); objorder.price = Convert.ToDecimal(lblPrice); objorder.qty = Convert.ToInt32(TxtQty); objorder.orderid = Convert.ToInt32(order_id); if (Convert.ToInt32(GlobleDiscount.Replace("%", "")) > 0) { objorder.finalPrice = Convert.ToDecimal(Convert.ToDecimal(lblPrice) - ((Convert.ToDecimal(lblPrice) * Convert.ToInt32(GlobleDiscount.Replace("%", "")) / 100))); objorder.netprice = Convert.ToDecimal((Convert.ToDecimal(lblPrice) * Convert.ToInt32(TxtQty)) - ((Convert.ToDecimal(lblPrice) * Convert.ToInt32(TxtQty)) * Convert.ToInt32(GlobleDiscount.Replace("%", "")) / 100)); } else { objorder.finalPrice = Convert.ToDecimal(lblPrice); objorder.netprice = Convert.ToDecimal(Convert.ToDecimal(lblPrice) * Convert.ToInt32(TxtQty)); } DataTable dtord = new DataTable(); dtord = objorder.GetOrderDetailByproIdordId(); if (dtord.Rows.Count > 0) { objorder.UpdateOrderDetail(); } else { objorder.InsertOrderDetail(); } if (Convert.ToInt32(GlobleDiscount.Replace("%", "")) > 0) { netPayment = Convert.ToDecimal(Convert.ToDecimal(netPayment) + (Convert.ToDecimal(objorder.netprice) - (Convert.ToDecimal(objorder.netprice) * Convert.ToInt32(GlobleDiscount.Replace("%", "")) / 100))); } else { netPayment = Convert.ToDecimal(Convert.ToDecimal(netPayment) + Convert.ToDecimal(objorder.netprice)); } } else { Session["msg"] = "Please enter quentity less than " + Inventory + " for this product : " + lblproName; lblerror.Visible = true; lblerrors.Text = "Please enter quentity less than " + Inventory + " for this product : " + lblproName; } } catch (Exception ex) { throw ex; } finally { objorder = null; } } } } // add into order if (ordFlag == true) { orderManager objordertotal = new orderManager(); customerManager objcust = new customerManager(); try { objordertotal.orderid = order_id; decimal TotalAmmount = objordertotal.GetSumOfItemPriceUsingOrderId(); if (TotalAmmount != 0) { netPayment = TotalAmmount; } objordertotal.totalammount = Convert.ToDecimal(netPayment); if (rbtCOD.Checked == true) { objordertotal.payType = Convert.ToInt32(System.Configuration.ConfigurationManager.AppSettings["PayTypeCase"]); } if (rbtCredit.Checked == true) { objordertotal.payType = Convert.ToInt32(System.Configuration.ConfigurationManager.AppSettings["PayTypeCredit"]); } objordertotal.contactName = Convert.ToString(strCustomerName); objordertotal.UpdateOrder(); hidorderid.Value = Convert.ToString(order_id); Session["OrderId"] = Convert.ToString(order_id); Session["cust_name"] = Convert.ToString(txtCustomer.Text.Trim()); GetOrderDetails(); rbtCOD.Enabled = true; rbtCredit.Enabled = true; Response.Redirect("add_order.aspx?orderid=" + order_id + "&chkid=" + objordertotal.payType + "&customer=" + customer_id); } catch (Exception o) { throw o; } finally { objordertotal = null; objcust = null; } } }
protected void Page_Load(object sender, EventArgs e) { Page.Title = "Add Order - " + System.Configuration.ConfigurationManager.AppSettings["AminPageTitle"]; GVOrder.PageSize = Convert.ToInt32(System.Configuration.ConfigurationManager.AppSettings["Pagging"]); gvAdmin.PageSize = Convert.ToInt32(System.Configuration.ConfigurationManager.AppSettings["Pagging"]); ltrheading.Text = "Add Order"; this.Form.DefaultButton = btnsearch.UniqueID; if (!IsPostBack) { BindProduct(); if (Session["cust_name"] != null) { txtCustomer.Text = Session["cust_name"].ToString(); } //if (Session["OrderId"] != null) //{ // GetOrderDetails(); //} if (lblTotalPayAmmount.Text == "" || lblTotalPayAmmount.Text == "0.00 SAR") { lnkEdit.Enabled = false; } if (Request.QueryString["orderid"] != null) { GetOrderDetails(); if (lblTotalPayAmmount.Text == "" || lblTotalPayAmmount.Text == "0.00 SAR") { lnkEdit.Enabled = false; } else { lnkEdit.Enabled = true; } hidCustomerId.Value = Request.QueryString["customer"].ToString(); if (Session["msg"].ToString() != "") { lblmsg.Visible = true; lblmsgs.Text = Session["msg"].ToString(); } } if (Request.QueryString["chkid"] != null) { if (Request.QueryString["chkid"] == Convert.ToString(1)) { rbtCOD.Checked = true; lblDelivertType.Text = "Cash on delivery"; } if (Request.QueryString["chkid"] == Convert.ToString(2)) { string creditLimits = ""; customerManager objcust = new customerManager(); if (Session["cust_name"].ToString() != "") { objcust.contactName = Session["cust_name"].ToString(); objcust.companyName = Session["cust_name"].ToString(); creditLimits = objcust.GetCustomerCreditFromName(); if (lblTotalPayAmmount.Text != "") { if (Convert.ToDecimal(creditLimits.Trim()) < Convert.ToDecimal(lblTotalPayAmmount.Text.Replace("SAR", "").Trim())) { rbtCOD.Checked = true; lblDelivertType.Text = "Cash on delivery"; } else { rbtCredit.Checked = true; lblDelivertType.Text = "Credit"; } } } } } if (lblTotalPayAmmount.Text != "") { rbtCOD.Enabled = true; rbtCredit.Enabled = true; } } }
//Bind product private void BindCustomer(string search = "") { this.Form.DefaultButton = imgbtnSearch.UniqueID; customerManager objproduct = new customerManager(); DataTable dtadmin = new DataTable(); try { if (txtsearch.Text != "") { objproduct.contactName = txtsearch.Text.Trim(); } else { objproduct.contactName = txtsearch.Text.Trim(); } if (pageNo == 0) { pageNo = 1; } objproduct.pageNo = pageNo; objproduct.pageSize = pageSize; objproduct.SortExpression = SortExpression; querystring = "&pageSize=" + ddlpageSize.SelectedValue + "&key=" + txtsearch.Text; dtadmin = objproduct.SearchItem(); totalrecs = objproduct.TotalRecord; if (pageNo == 1) { objproduct.pageNo = 1; pageNo = 1; } else if (pageNo == 0) { objproduct.pageNo = 1; pageNo = 1; } else { objproduct.pageNo = (pageNo - 1) * pageSize; } objproduct.pageSize = pageSize; totalpages = totalrecs / pageSize; if ((totalrecs % pageSize) > 0 && (totalrecs > pageSize)) { totalpages += 1; } gvAdmin.DataSource = dtadmin; gvAdmin.DataBind(); if (dtadmin.Rows.Count > 0) { int startRowOnPage = (gvAdmin.PageIndex * gvAdmin.PageSize) + 1; int lastRowOnPage = startRowOnPage + gvAdmin.Rows.Count - 1; int totalRows = totalrecs; ltrcountrecord.Text = "<div class=\"countdiv\">Showing " + startRowOnPage.ToString() + " to " + lastRowOnPage + " of " + totalRows + " entries</div>"; } String strpaging = CommonFunctions.AdminPagingv2(totalpages, pageNo, querystring, "viewcustomer.aspx"); ltrpaggingbottom.Text = strpaging; //Ltrup.Text = strpaging; LoadDropDownList(); } catch (Exception ex) { throw ex; } finally { dtadmin.Dispose(); objproduct = null; } }