protected void Button1_Click(object sender, EventArgs e) { User sUser = (User)Session["user"]; if (sUser == null || sUser.user_type != 1) { Response.Redirect("~/m/Login.aspx"); } User dUser = new UserController().actionGetUserByID(sUser.id); RequisitionController requisitionController = new RequisitionController(); ApplicationLayer.Requisition requisition = new ApplicationLayer.Requisition(); requisition.user_obj = dUser.id; requisition.stationery = Convert.ToInt32(ui_id_hidden.Value); requisition.quantity = Convert.ToInt32(ui_quantity.Text); requisition.department = Convert.ToInt32(dUser.department); Message message = requisitionController.actionCreateRequisition(requisition); if (message.condition) { Response.Cookies.Add(new HttpCookie("flash_message", "Successfully Requested.") { Path = "/" }); Response.Cookies.Add(new HttpCookie("flash_css", "alert alert-success") { Path = "/" }); Response.Redirect("~/m/DepartmentEmployee/Stationeries.aspx"); } else { Response.Cookies.Add(new HttpCookie("flash_message", "Requisition Fail. <br />" + message.message) { Path = "/" }); Response.Cookies.Add(new HttpCookie("flash_css", "alert alert-error") { Path = "/" }); return; } }
public string makeRequisition(int userId, string stationeryName, int quantity) { StationeryController stController = new StationeryController(); Requisition requisition = new Requisition(); // System.Diagnostics.Debug.WriteLine("inside actionGetStationeryIdByName::" + name); string newstationeryName = stationeryName.Replace('_', ' '); // System.Diagnostics.Debug.WriteLine("inside actionGetStationeryIdByName::" + newstationeryName); int stationeryId = Convert.ToInt32(stController.actionGetStationeryIdByName(newstationeryName)); requisition.stationery = stationeryId; requisition.quantity = quantity; requisition.user_obj = userId; //hardcoded department id requisition.department = 8; requisition.user_approved_by = null; RequisitionController requisitionController = new RequisitionController(); Message msg = requisitionController.actionCreateRequisition(requisition); if (msg.condition) { System.Diagnostics.Debug.WriteLine("success"); return "success"; } else { System.Diagnostics.Debug.WriteLine("fail"); return "fail"; } }
public static string MakeRequisition(object jsonParam) { User user = (User)HttpContext.Current.Session["user"]; if (user == null) { return null; } int empId = user.id; String valueString = jsonParam.ToString(); string[] values = valueString.Split('.'); int stId= Convert.ToInt16(values[0]); int qty= Convert.ToInt16(values[1]); int depId = Convert.ToInt32(user.department); Requisition requisition = new Requisition(); requisition.stationery = stId; requisition.quantity = qty; requisition.user_obj = empId; requisition.department = depId; requisition.user_approved_by = null; RequisitionController requisitionController = new RequisitionController(); Message msg= requisitionController.actionCreateRequisition(requisition); if (msg.condition) { //return msg.message; return "success"; } else { //return msg.message; return "fail"; } // System.Diagnostics.Debug.WriteLine(" inside MakeRequisition " + msg); // return "Hi this is response from MakeRequisition"; }