// AJAX // Reject Department Requests public ActionResult Ajax_Reject_Department_Request(ajax_model ajax_model_data) { ajax_model ajax_data = new ajax_model { name = ajax_model_data.name, main_data = ajax_model_data.main_data, }; using (var db = new DataBaseContext()) { List <orders> order_lis = db.orders_repository.Where(or => or.staff_obj.department_obj.department_name == ajax_data.name).ToList(); foreach (orders or in order_lis) { or.order_status = "Rejected_by_Clerk"; db.SaveChanges(); } } object reply_to_client = new { key_itemname_lis = "SUCCESS", }; //Email Notification staff rep = StaffData.GetStaffByName(DepartmentData.GetRepresentativebyDepName(ajax_data.name)); string emailadd = rep.email; Task task = Task.Run(() => { EmailNotification.SendNotificationEmailToEmployee(emailadd, "New Disbursment Order Reminder", "There is a new disbursment order to your department was rejected by store clerk."); }); return(Json(reply_to_client, JsonRequestBehavior.AllowGet)); }
public ActionResult Ajax_Reject_Request_Item(ajax_model ajax_data) { ajax_model data = new ajax_model { name = ajax_data.name, main_data = ajax_data.main_data, }; using (var db = new DataBaseContext()) { int temp_id = Int32.Parse(data.main_data[0]); orders temp_order = db.orders_repository.Where(o => o.ordersId == temp_id).FirstOrDefault(); temp_order.order_status = "Reject_by_Head"; db.SaveChanges(); } object reply_to_client = new { key_itemname_lis = "SUCCESS", }; //Email Notification orders ord = OrdersData.GetOrderById(Int32.Parse(data.main_data[0])); string emailadd = StaffData.GetStaffByName(ord.staff_obj.name).email; Task task = Task.Run(() => { EmailNotification.SendNotificationEmailToEmployee(emailadd, "Requisition Progress Updated", "Your requisition was just rejected by manager, please check."); }); return(Json(reply_to_client, JsonRequestBehavior.AllowGet)); }
// ------------------------------------------------------------------------------------ // -------------------------- CREATE REQUEST ITEM ------------------------------------------ public ActionResult View_Request_Item() { string user_name = Session["UserName"].ToString(); using (var db = new DataBaseContext()) { staff staff_obj = db.staff_repository.Where(x => x.name == user_name).Select(x => x).FirstOrDefault(); List <orders> orders_lis = db.orders_repository.Where(x => x.staff_obj.staffId == staff_obj.staffId && (x.order_status == "pending" || x.order_status == "Reject_by_Head")).ToList(); List <string> item_description_lis = new List <string>(); foreach (orders or in orders_lis) { item_description_lis.Add(or.item_obj.item_description); } ViewBag.item_description_lis = item_description_lis; ViewBag.order_lis = (List <orders>)orders_lis; } //Email Notification staff s = StaffData.GetStaffByName((string)Session["UserName"]); string emailadd = StaffData.GetStaffByName(s.department_obj.head_name).email; Task task = Task.Run(() => { EmailNotification.SendNotificationEmailToEmployee(emailadd, "New Requisition Reminder", "There is a new requistion for your approval, please check."); }); return(View()); }
public ActionResult Delegate_Authority_Staff(FormCollection form_data) { string staff_name = form_data["staff_list"]; string duty_start_date = form_data["start_date_box"].ToString(); string duty_end_date = form_data["end_date_box"].ToString(); List <staff_representative> list = StaffRepData.GetAllNotExpired(); foreach (staff_representative st in list) { if (StaffData.GetStaffById(st.staff_representativeId).name.Equals(staff_name)) { return(RedirectToAction("Delegate_Authority", "Head")); } } using (var db = new DataBaseContext()) { staff staff_obj = db.staff_repository.Where(s => s.name == staff_name).FirstOrDefault(); staff_representative staff_representative_obj = new staff_representative(duty_start_date, duty_end_date, staff_obj, "Pending"); db.staff_representative_repository.Add(staff_representative_obj); db.SaveChanges(); if (duty_start_date.Equals(DateTime.Today.Date.ToString("yyyy-MM-dd"))) { StaffRepData.StartDelegation(staff_obj.staffId); } } //Email Notification staff sta = StaffData.GetStaffByName(staff_name); string emailadd = sta.email; Task task = Task.Run(() => { EmailNotification.SendNotificationEmailToEmployee(emailadd, "New Delegation Reminder", "Your were just be delegated as temporary department head, please check it out."); }); return(RedirectToAction("Delegate_Authority", "Head")); }
public ActionResult Create_Stationary_Retrival_Form(FormCollection form_data) { using (var db = new DataBaseContext()) { int input_bx_count = Int32.Parse(form_data["input_bx_count_name"]); for (int i = 1; i <= input_bx_count; i++) { string actual_quantity_delivered = form_data["Actual_Quantity_Delivered_" + i]; string store_order_id = form_data["Store_Order_ID_" + i]; string[] store_order_id_lis = store_order_id.Split('_'); System.Diagnostics.Debug.WriteLine("STORE ID LIST: " + store_order_id_lis); System.Diagnostics.Debug.WriteLine("ACTUAL QUANTITY : " + actual_quantity_delivered); if (store_order_id_lis.Length == 1) { int order_id = Int32.Parse(store_order_id_lis[0]); int actual_quantity = Int32.Parse(actual_quantity_delivered); orders order_obj = db.orders_repository.Where(x => x.ordersId == order_id).FirstOrDefault(); order_obj.actual_delivered_quantity_by_clerk = actual_quantity; order_obj.order_status = "Approved_by_Clerk"; order_obj.delivered_order_date = DateTime.Now.ToString(); db.SaveChanges(); items_warehouse item_ware_obj = db.item_warehouses_repository.Where(x => x.item.itemId == order_obj.item_obj.itemId).FirstOrDefault(); item_ware_obj.stock_balance = item_ware_obj.stock_balance - actual_quantity; order_obj.delivered_order_date = DateTime.Now.ToString(); db.SaveChanges(); //Email Notification staff rep = StaffData.GetStaffByName(order_obj.staff_obj.department_obj.representative_name); string emailadd = rep.email; Task task = Task.Run(() => { EmailNotification.SendNotificationEmailToEmployee(emailadd, "New Disbursment Order Reminder", "There is a new disbursment order to your department was just approved by store clerk. please get ready to receive it."); }); } else { int actual_quantity = Int32.Parse(actual_quantity_delivered); int temp_item_id = 0; for (int j = 0; j < store_order_id_lis.Length; j++) { int temp_order_id = Int32.Parse(store_order_id_lis[j]); orders order_obj = db.orders_repository.Where(x => x.ordersId == temp_order_id).FirstOrDefault(); temp_item_id = order_obj.item_obj.itemId; if (actual_quantity - order_obj.proposed_quantity > 0) { int temp_amount = actual_quantity - order_obj.proposed_quantity; actual_quantity = actual_quantity - order_obj.proposed_quantity; order_obj.actual_delivered_quantity_by_clerk = temp_amount; order_obj.order_status = "Approved_by_Clerk"; order_obj.delivered_order_date = DateTime.Now.ToString(); db.SaveChanges(); //Email Notification staff rep = StaffData.GetStaffByName(order_obj.staff_obj.department_obj.representative_name); string emailadd = rep.email; Task task = Task.Run(() => { EmailNotification.SendNotificationEmailToEmployee(emailadd, "New Disbursment Order Reminder", "There is a new disbursment order to your department was just approved by store clerk. please get ready to receive it."); }); } else { order_obj.actual_delivered_quantity_by_clerk = actual_quantity; order_obj.order_status = "Approved_by_Clerk"; order_obj.delivered_order_date = DateTime.Now.ToString(); db.SaveChanges(); } } items_warehouse item_ware_obj = db.item_warehouses_repository.Where(x => x.item.itemId == temp_item_id).FirstOrDefault(); item_ware_obj.stock_balance = item_ware_obj.stock_balance - actual_quantity; db.SaveChanges(); } } return(RedirectToAction("View_Adjustment_Voucher", "Clerk")); } }
// Approve Department Request public ActionResult Ajax_Approve_Department_Request(ajax_model ajax_model_data) { string quantity_status = ""; int stock_level = 0; string order_id_status = ""; Dictionary <string, int> item_and_quantity_of_department = new Dictionary <string, int>(); ajax_model ajax_data = new ajax_model { name = ajax_model_data.name, main_data = ajax_model_data.main_data, }; using (var db = new DataBaseContext()) { List <orders> order_lis = db.orders_repository.Where(or => or.staff_obj.department_obj.department_name == ajax_data.name && or.order_status == "Approved_by_Head").ToList(); Dictionary <int, int> item_quantity = new Dictionary <int, int>(); List <items_warehouse> item_ware_lis = db.item_warehouses_repository.ToList(); foreach (items_warehouse temp_item in item_ware_lis) { item_quantity.Add(temp_item.item.itemId, temp_item.stock_balance); } for (int i = 0; i < order_lis.Count; i++) { orders temp_order = order_lis[i]; stock_level = item_quantity[temp_order.item_obj.itemId]; stock_level = stock_level - temp_order.proposed_quantity; order_id_status = temp_order.ordersId.ToString(); // For Stock Card item_and_quantity_of_department.Add(temp_order.item_obj.item_description, temp_order.proposed_quantity); if (stock_level < 0) { quantity_status = "OUT_OF_STOCK"; break; } else { item_quantity[temp_order.item_obj.itemId] = stock_level; } } if (quantity_status != "OUT_OF_STOCK") { foreach (KeyValuePair <int, int> data in item_quantity) { items_warehouse item_ware_obj = db.item_warehouses_repository.Where(k => k.item.itemId == data.Key).FirstOrDefault(); item_ware_obj.stock_balance = data.Value; db.SaveChanges(); quantity_status = "QUANTITY_SUFFICIENT"; // Add ACTUAL_QUANTITY and DELIVERY DATE foreach (orders temp_order in order_lis) { temp_order.actual_delivered_quantity_by_clerk = temp_order.proposed_quantity; temp_order.delivered_order_date = DateTime.Now.ToString(); db.SaveChanges(); } } // For Stock Card foreach (KeyValuePair <string, int> temp_data in item_and_quantity_of_department) { item item_obj = db.item_warehouse_repository.Where(i => i.item_description == temp_data.Key).FirstOrDefault(); // STOCK CARD UPDATE int stockbalance = StockcardData.GetStockBalanceByItemId(item_obj.itemId); stock_card stock_card_obj = new stock_card(ajax_data.name, DateTime.Now.ToString(), " - " + temp_data.Value, item_obj, stockbalance - temp_data.Value); db.stock_card_repository.Add(stock_card_obj); db.SaveChanges(); } foreach (orders temp_order in order_lis) { temp_order.order_status = "Approved_by_Clerk"; db.SaveChanges(); } } } object reply_to_client = new { item_quantity_status = quantity_status, stock_level_status = stock_level, order_identity_status = order_id_status, }; //Email Notification staff rep = StaffData.GetStaffByName(DepartmentData.GetRepresentativebyDepName(ajax_data.name)); string emailadd = rep.email; Task task = Task.Run(() => { EmailNotification.SendNotificationEmailToEmployee(emailadd, "New Disbursment Order Reminder", "There is a new disbursment order to your department was just approved by store clerk. please get ready to receive it."); }); return(Json(reply_to_client, JsonRequestBehavior.AllowGet)); }