public static string updatePaymentType(PaymentType pt, string paymentTypeName) { if (paymentTypeName.Length <= 0) { return("Payment type must not be empty!"); } else if (paymentTypeName.Length < 3) { return("Payment type name must at least 3 characters!"); } else if (!paymentTypeName.Equals(pt.PaymentTypeName) && !PaymentTypeHandler.validatePaymentTypeName(paymentTypeName)) { return(String.Format("These payment type name has already taken! " + "Use old name: '{0}' or other non-existent payment type instead.", pt.PaymentTypeName)); } try { PaymentTypeHandler.updatePaymentType(pt.PaymentTypeID, paymentTypeName); } catch (Exception ex) { Console.WriteLine(ex.ToString()); return("Database update on server failure, please try again!"); } return(""); }
protected void Page_Load(object sender, EventArgs e) { Table1.Visible = false; Updatebtn.Visible = false; lblerror.Visible = false; lblPaymentTypeOld.Visible = false; lblOldPayment.Visible = false; if (Session[Constant.Keys.AUTH] != null) { int id = Int32.Parse(Request.QueryString["id"]); User user = (User)Session[Constant.Keys.AUTH]; if (user.RoleID == 1) { Table1.Visible = true; Updatebtn.Visible = true; lblerror.Visible = true; lblPaymentTypeOld.Visible = true; lblOldPayment.Visible = true; lblOldPayment.Text = PaymentTypeHandler.getName(id); } else { var redirecTo = Constant.Routes.HOME_ROUTE; Response.Redirect(redirecTo); } } else { var redirecTo = Constant.Routes.HOME_ROUTE; Response.Redirect(redirecTo); } }
public void validateUpdatePaymentType(TextBox txtPaymentType, Label lblErrorPaymentType, Label lblSuccess) { int ID = Convert.ToInt32(HttpContext.Current.Request.QueryString["paymenttypeid"]); string name = txtPaymentType.Text; List <PaymentType> check = new PaymentTypeHandler().GetSameNameUpdate(name); int flag = 0; foreach (var item in check) { if (item.ID != ID) { flag = 1; break; } } if (flag == 1) { lblErrorPaymentType.Visible = true; return; } PaymentType newPaymentType = new PaymentTypeFactory().CreatePaymentType(name); new PaymentTypeHandler().UpdatePaymentType(newPaymentType, ID); lblSuccess.Visible = true; lblErrorPaymentType.Visible = false; }
public static String checkPaymentTypes(String PaymentTypeID) { string error = ""; int PaymentID = 0; bool flag = true; try { PaymentID = int.Parse(PaymentTypeID); } catch (Exception ex) { if (ex != null) { flag = false; error = "Input Payment Type ID must be a number"; } } if (flag) { if (!PaymentTypeHandler.getByID(int.Parse(PaymentTypeID))) { error = "Payment Type ID is invalid"; } } return(error); }
public static string insertPaymentType(string paymentTypeName) { if (paymentTypeName.Length <= 0) { return("Payment type must not be empty!"); } else if (paymentTypeName.Length < 3) { return("Payment type name must at least 3 characters!"); } else if (!PaymentTypeHandler.validatePaymentTypeName(paymentTypeName)) { return("These payment type name has already taken!"); } try { PaymentTypeHandler.addPaymentType(paymentTypeName); } catch (Exception ex) { Console.WriteLine(ex.ToString()); return("Database update on server failure, please try again!"); } return(""); }
protected void Page_Load(object sender, EventArgs e) { if (Session["id"] == null) { Response.Redirect("~/views/Login.aspx"); } if (UserHandler.IsAdmin(Session["id"].ToString()) == false) { Response.Redirect("~/views/Homeaspx.aspx"); } if (Page.IsPostBack == false) { if (Request.QueryString["payId"] != null) { int payId = Int32.Parse(Request.QueryString["payId"]); PaymentType paytype = PaymentTypeHandler.GetPaymentType(payId); PaymentTypeName.Text = paytype.Type; paytypeTxt.Text = paytype.Type; //payIdTxt.Text = payId.ToString(); } else { Response.Redirect("~/PaymentType/ViewPaymentType.aspx"); } } }
public static DataSet1 GenerateData(List <HeaderTransaction> transactionList) { DataSet1 dataSet = new DataSet1(); var headerTransactionTable = dataSet.HeaderTransaction; var detailTransactionTable = dataSet.DetailTransaction; foreach (var ht in transactionList) { var headerTransactionRow = headerTransactionTable.NewRow(); headerTransactionRow["TransactionId"] = ht.Id; User user = UserHandler.findUserByID(ht.UserID.GetValueOrDefault()); String paymentTypeName = PaymentTypeHandler.getPaymentTypeByID(ht.PaymentTypeID).Type; headerTransactionRow["UserName"] = user.Name; headerTransactionRow["Date"] = ht.Date; headerTransactionRow["PaymentTypeName"] = paymentTypeName; long grandTotal = 0; foreach (var dt in ht.DetailTransactions) { var detailTransactionRow = detailTransactionTable.NewRow(); Product product = ProductHandler.getProductByID(dt.ProductID); detailTransactionRow["TransactionId"] = dt.TransactionID; detailTransactionRow["ProductName"] = product.Name; detailTransactionRow["ProductPrice"] = "Rp " + product.Price; detailTransactionRow["Quantity"] = dt.Quantity; int subTotal = dt.Quantity * product.Price; detailTransactionRow["SubTotal"] = "Rp " + subTotal; grandTotal += subTotal; detailTransactionTable.Rows.Add(detailTransactionRow); } headerTransactionRow["GrandTotal"] = "Rp " + grandTotal; headerTransactionTable.Rows.Add(headerTransactionRow); } return(dataSet); }
public void initPage(TextBox txtPaymentType) { int ID = Convert.ToInt32(HttpContext.Current.Request.QueryString["paymenttypeid"]); PaymentType currentData = new PaymentTypeHandler().GetPaymentTypeByID(ID); txtPaymentType.Text = currentData.Type; }
public static PaymentType createPaymentType(String type) { PaymentType pt = new PaymentType(); pt.ID = PaymentTypeHandler.getLastPaymentTypeID() + 1; pt.Type = type; return(pt); }
public static void updatePaymentType(int id, string name, out string errorMessage) { bool success = checkConstraintPaymentType(name, out errorMessage); if (success == true) { errorMessage = "Success"; PaymentTypeHandler.updatePaymentType(id, name); } }
public static string delete(int ID) { string error = ""; if (PaymentTypeHandler.isPaymentTypeReferenced(ID)) { error = "Failed to delete selected payment type"; } return(error); }
protected void tablePaymentType_RowDeleting(object sender, GridViewDeleteEventArgs e) { int index = e.RowIndex; string payId = tablePaymentType.Rows[index].Cells[2].Text; int id = Int32.Parse(payId); PaymentTypeHandler.DeletePaymentType(id); Response.Redirect(Request.RawUrl); }
public static Response UpdatePaymentType(int id, string type) { if (type == "" || type.Length < 3) { return(new Response(false, "Please insert the type and/or a minimum of 3 character")); } if (PaymentTypeHandler.IsUnique(type) == false) { return(new Response(false, "Payment Type needs to be unique")); } return(new Response(PaymentTypeHandler.UpdatePaymentType(id, type), "Product Type has been inserted")); }
public static string deletePaymentType(PaymentType pt) { try { PaymentTypeHandler.deletePaymentType(pt.PaymentTypeID); } catch (Exception ex) { Console.WriteLine(ex.ToString()); return("Database update on server failure, please try again!"); } return(""); }
protected void Updatebtn_Click(object sender, EventArgs e) { int id = Int32.Parse(Request.QueryString["id"]); string messageError = ""; messageError = PaymentTypeController.update(updateTxt.Text); if (messageError != "") { lblerror.Text = messageError; } else { PaymentTypeHandler.update(id, updateTxt.Text); lblerror.Text = "Update Success"; } }
protected void Delete_Click(object sender, EventArgs e) { int id = Int32.Parse((sender as LinkButton).CommandArgument); string messageError = PaymentTypeController.delete(id); if (messageError != "") { lblErrorViewPaymentType.Text = messageError; } else { PaymentTypeHandler.remove(id); Load_PaymentType(); Response.Redirect(Constant.Routes.VIEW_PAYMENT_TYPE); lblErrorViewPaymentType.Text = "Payment type has been deleted"; } }
public static void createPaymentType(string name, out string errorMessage) { PaymentType payment = getPaymentbyName(name); if (payment == null) { bool success = checkConstraintPaymentType(name, out errorMessage); if (success == true) { errorMessage = "Success"; PaymentTypeHandler.createPaymentType(name); } } else { errorMessage = "Payment Type is Already Registered"; } }
public static int PaymentTypeValidation(String type) { PaymentType Type = PaymentTypeHandler.getPaymentTypeByName(type); if (type == "") { return(-1); } else if (type.Length < 3) { return(-2); } else if (Type != null) { return(-3); } return(1); }
public static string update(String type) { string error = ""; String tipe = type; if (tipe == "") { error = "Payment Type name must be filled"; } else if (tipe.Length < 3) { error = "Payment type name must be consists of 3 characters or more"; } else if (!PaymentTypeHandler.checkPaymentTypeIsUnique(tipe)) { error = "Product type name must be unique"; } return(error); }
protected void NewPaymentbtn_Click(object sender, EventArgs e) { String type = Typetxt.Text; String messageError = ""; messageError = PaymentTypeController.insert(type); if (messageError != "") { insLabelError.Text = messageError; } else { PaymentTypeHandler.add(type); insLabelError.Text = "Payment type has been registered"; } }
private void LoadComboModalitaPagamento() { //preparo la combo delle zone cboModAcconto.Properties.Items.Clear(); cboModSaldo.Properties.Items.Clear(); PaymentTypeHandler h = new PaymentTypeHandler(); IList l = h.GetAll(); //la riempio cboModAcconto.Properties.Items.Add(""); cboModAcconto.Properties.Items.AddRange(l); cboModSaldo.Properties.Items.Add(""); cboModSaldo.Properties.Items.AddRange(l); //seleziono quella iniziale cboModAcconto.SelectedIndex = 0; cboModSaldo.SelectedIndex = 0; }
public void InitPage(object RoleId, object UserID, GridView gridCart, Label grandTotalLabel, DropDownList ddlPaymentType) { if (Convert.ToInt32(RoleId) == 1 && UserID != null) { int UserId = Int32.Parse(UserID.ToString()); CartHandler.updateDataJoin(gridCart, UserId); int GrandTotal = 0; gridCart.Columns[5].Visible = true; for (int i = 0; i < gridCart.Rows.Count; ++i) { GrandTotal += Convert.ToInt32(gridCart.Rows[i].Cells[4].Text.ToString()); } grandTotalLabel.Text = "Grand Total = " + GrandTotal.ToString(); List <PaymentType> dataPT = new PaymentTypeHandler().GetAllPaymentType(); ddlPaymentType.DataSource = dataPT; ddlPaymentType.DataTextField = "Type"; ddlPaymentType.DataValueField = "ID"; ddlPaymentType.DataBind(); } }
public static Response CheckOut(List <DetailedCart> Cart, string paymentId, int userId) { if (paymentId == "" || paymentId.All(char.IsDigit) != true) { return(new Response(false, "Payment ID cannot be empty or non numeric")); } int _paymentId = Int32.Parse(paymentId); if (PaymentTypeHandler.GetPaymentType(_paymentId) == null) { return(new Response(false, "Wrong Payment Type ID")); } if (Cart == null) { return(new Response(false, "Cart Cannot be empty")); } TransactionHandler.CheckOut(Cart, _paymentId, userId); return(new Response(true, "Cart successfully checked out")); }
public static PaymentType requestPaymentTypeObject(int id) { return(PaymentTypeHandler.getPaymentTypeObject(id)); }
public static void requestUpdatePayment(int id, string name) { PaymentTypeHandler.updatePayment(id, name); }
public static bool checkDuplicateName(string name) { return(PaymentTypeHandler.checkNameExist(name)); }
private void loadData() { viewPaymentTypeGrid.DataSource = PaymentTypeHandler.getAll(); viewPaymentTypeGrid.DataBind(); }
public static PaymentType getPaymentTypeByID(int paymentTypeID) { return(PaymentTypeHandler.getPaymentTypeByID(paymentTypeID)); }
public static List <PaymentType> getAllPaymentTypes() { return(PaymentTypeHandler.getAllPaymentTypes()); }
public static PaymentType getPaymentbyName(string name) { return(PaymentTypeHandler.getPaymentbyName(name)); }