private void BindEmployeeDiscount() { EmployeeDiscounts discount = new EmployeeDiscounts(); discount.EmployeeID = Utility.GetUserIdFromUserName(HttpContext.Current.User.Identity.Name); DataTable table = discount.SelectOneByEmployeeID(); if (table.Rows.Count > 0) { Double availableDiscount = (discount.Discount == SqlMoney.Null) ? 0.00 : discount.Discount.ToDouble(); lblEmployeeDiscount.Text = "Employee Discount: " + discount.Discount.ToString(); hidEmployeeDiscount.Value = availableDiscount.ToString(); hidDiscountId.Value = discount.DiscountID.ToString(); string discUnit = (discount.UnitOfDiscount != SqlInt32.Null || discount.UnitOfDiscount != 0) ? discount.UnitOfDiscount.ToString() : "2"; switch (discUnit) { case "1": lblEmployeeDiscountUnit.Text = "KD"; hidEmployeeDiscountUnit.Value = "1"; break; case "2": lblEmployeeDiscountUnit.Text = "%"; hidEmployeeDiscountUnit.Value = "2"; break; default: lblEmployeeDiscountUnit.Text = "KD"; hidEmployeeDiscountUnit.Value = "1"; break; } } }
private void DeleteEmployeeDiscount(int discountId) { EmployeeDiscounts discount = new EmployeeDiscounts(); discount.DiscountID = discountId; discount.SelectOne(); discount.Delete(); BindGridView(); }
/* * private void BindDiscountByEmployee(int rateId) * { * DataTable table = new DiscountsOffered().SelectAll(); * SqlMoney discount = new SqlMoney(); * discount = 0; * var results = (from m in table.AsEnumerable() * where m.Field<int>("Employee_ID") == 1 //&& m.Field<int>("Rate_ID") == rateId * select m); * foreach (var result in results) * { * discount = SqlMoney.Parse(result["Allowed_Discount"].ToString()); * if (result["Rate_ID"].ToString().Equals(rateId.ToString())) * { * discount = SqlMoney.Parse(result["Allowed_Discount"].ToString()); * break; * } * } * lblSalesPersonDiscount.InnerText = discount.ToString(); * lblTotalAmount.Text = (SqlMoney.Parse(lblRate.Text) - SqlMoney.Parse(lblSalesPersonDiscount.InnerText)).ToString(); * * }*/ private void BindEmployeeDiscount() { hidEmployeeDiscount.Value = "0"; hidEmployeeDiscountUnit.Value = "0"; EmployeeDiscounts discount = new EmployeeDiscounts(); discount.EmployeeID = 1; DataTable table = discount.SelectOneByEmployeeID(); if (table.Rows.Count > 0) { hidEmployeeDiscount.Value = ((discount.Discount.ToString() != null || discount.Discount.ToString() != string.Empty) && discount.Discount.ToString() != "") ? discount.Discount.ToString() : "0"; hidEmployeeDiscountUnit.Value = ((discount.UnitOfDiscount.ToString() != null || discount.UnitOfDiscount.ToString() != string.Empty) && discount.UnitOfDiscount.ToString() != "") ? discount.UnitOfDiscount.ToString() : "0"; } }
protected void Page_Load(object sender, EventArgs e) { if (!Page.IsPostBack) { GetUsers(); int discountID = 0; Session.Remove("Prop_Action"); if (Request.QueryString["DiscountID"] != null) { discountID = Convert.ToInt32(Request.QueryString["DiscountID"]); txtdiscountID.Value = discountID.ToString(); Session["Prop_Action"] = "U"; } if (Session["Prop_Action"] == "U") { // int proID= int.Parse(Session["Pro_ID"].ToString()); EmployeeDiscounts disc = new EmployeeDiscounts(); disc.DiscountID = discountID; disc.SelectOne(); Employees employee = new Employees(); employee.Employee_ID = disc.EmployeeID; employee.SelectOne(); AspNetUsers user = new AspNetUsers(); user.UserName = employee.UserName.ToString(); user.SelectOneByUserName(); CboUser.SelectedValue = user.Id.ToString(); CboUnit.SelectedValue = disc.UnitOfDiscount.ToString(); cboStatus.SelectedValue = disc.DiscountStatus.ToString(); txtDiscount.Text = disc.Discount.ToString(); } } }
private DataTable GetDiscounts() { DataTable table = new EmployeeDiscounts().SelectAll(); return(table); }
protected void btnSave_Click(object sender, EventArgs e) { lblMsg.Text = ""; if (string.IsNullOrEmpty(txtDiscount.Text)) { lblMsg.Text = "Invalid Discount ."; lblMsg.ForeColor = Color.Red; return; } Employees _employee = new Employees(); try { _employee.UserName = CboUser.SelectedItem.Text; _employee.SelectOneByUserName(); if (_employee.ErrorCode != 0) { lblMsg.Text = _employee.ErrorDesc.ToString(); lblMsg.ForeColor = Color.Red; return; } } catch (Exception ee) {} try { EmployeeDiscounts em = new EmployeeDiscounts(); em.Discount = SqlMoney.Parse(txtDiscount.Text); em.EmployeeID = _employee.Employee_ID; if (Session["Prop_Action"] != "U") { em.DiscountStatus = 1; em.UnitOfDiscount = Int32.Parse(CboUnit.SelectedValue); em.CreatedUser = Utility.GetUserIdFromUserName(HttpContext.Current.User.Identity.Name); bool retval = em.Insert(); if (em.ErrorCode == 0) { lblMsg.Text = "Data Updated successfully."; lblMsg.ForeColor = Color.Green; } else { lblMsg.Text = em.ErrorDesc.ToString(); lblMsg.ForeColor = Color.Red; } // Response.Redirect("RoomTypes.aspx", true); } else { em.DiscountID = int.Parse(txtdiscountID.Value); em.DiscountStatus = int.Parse(cboStatus.SelectedItem.Value); em.UnitOfDiscount = Int32.Parse(CboUnit.SelectedValue); em.LastModifiedUser = Utility.GetUserIdFromUserName(HttpContext.Current.User.Identity.Name); em.LastModifiedDate = Utility.GetSqlDateTimeFromDateTime(DateTime.Now); em.Update(); if (em.ErrorCode == 0) { lblMsg.Text = "Data Saved successfully."; lblMsg.ForeColor = Color.Green; } else { lblMsg.Text = em.ErrorDesc.ToString(); lblMsg.ForeColor = Color.Red; } } } catch (Exception ex) { lblMsg.Text = "Data not Saved ."; lblMsg.ForeColor = Color.Red; } }