private void LoadTonerRequest(int pageIndex, int pageSize) { Business.Service.TonerRequest objTonnerRequest = new Business.Service.TonerRequest(); Entity.Service.TonerRequest tonerRequest = new Entity.Service.TonerRequest(); tonerRequest.PageIndex = pageIndex; tonerRequest.PageSize = pageSize; string callStatusIds = string.Empty; callStatusIds = string.Concat(((int)CallStatusType.TonerOpenForApproval).ToString(), ",", ((int)CallStatusType.TonerRequestInQueue).ToString(), ",", ((int)CallStatusType.TonerResponseGiven).ToString()); tonerRequest.MultipleCallStatusFilter = callStatusIds; if (HttpContext.Current.User.IsInRole(Entity.HR.Utility.CUSTOMER_LIST_SHOW_ALL)) { tonerRequest.AssignEngineer = 0; } else { tonerRequest.AssignEngineer = int.Parse(HttpContext.Current.User.Identity.Name); } DataSet response = objTonnerRequest.Service_TonnerRequest_GetAllMinimal(tonerRequest); gvTonnerRequestAsync.DataSource = response.Tables[0]; gvTonnerRequestAsync.VirtualItemCount = (response.Tables[1].Rows.Count > 0) ? Convert.ToInt32(response.Tables[1].Rows[0]["TotalCount"].ToString()) : 10; gvTonnerRequestAsync.DataBind(); }
protected void LoadTonnerRequest() { Business.Service.TonerRequest objTonnerRequest = new Business.Service.TonerRequest(); Entity.Service.TonerRequest tonnerRequest = new Entity.Service.TonerRequest(); tonnerRequest.CustomerId = int.Parse(HttpContext.Current.User.Identity.Name.Split('|')[(int)Constants.Customer.ID]); DataTable dt = objTonnerRequest.Service_TonerRequest_GetAll(tonnerRequest).Tables[0]; if (dt != null && dt.Rows.Count > 0) { gvTonnerRequest.DataSource = dt.AsEnumerable().Take(5).CopyToDataTable(); } else { gvTonnerRequest.DataSource = null; } gvTonnerRequest.DataBind(); }
public static Entity.Service.TonerRequest Service_TonnerRequest_GetByTonnerRequestId(int tonnerRequestid) { Entity.Service.TonerRequest tonnerRequest = new Entity.Service.TonerRequest(); using (SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["constr"].ToString())) { using (SqlCommand cmd = new SqlCommand()) { cmd.Connection = con; cmd.CommandType = CommandType.StoredProcedure; cmd.CommandText = "usp_Service_TonnerRequest_GetByRequestId"; cmd.Parameters.AddWithValue("@TonnerRequestId", tonnerRequestid); if (con.State == ConnectionState.Closed) { con.Open(); } using (SqlDataReader dr = cmd.ExecuteReader()) { if (dr.Read()) { if (dr.HasRows) { tonnerRequest.TonerRequestId = tonnerRequestid; tonnerRequest.RequestNo = dr["RequestNo"].ToString(); tonnerRequest.CustomerId = (dr["CustomerId_FK"] == DBNull.Value) ? 0 : int.Parse(dr["CustomerId_FK"].ToString()); tonnerRequest.ProductId = int.Parse(dr["ProductId_FK"].ToString()); tonnerRequest.RequestDateTime = Convert.ToDateTime(dr["RequestDateTime"].ToString()); tonnerRequest.A3BWMeterReading = (dr["A3BWMeterReading"] == DBNull.Value) ? 0 : int.Parse(dr["A3BWMeterReading"].ToString()); tonnerRequest.A4BWMeterReading = (dr["A4BWMeterReading"] == DBNull.Value) ? 0 : int.Parse(dr["A4BWMeterReading"].ToString()); tonnerRequest.A3CLMeterReading = (dr["A3CLMeterReading"] == DBNull.Value) ? 0 : int.Parse(dr["A3CLMeterReading"].ToString()); tonnerRequest.A4CLMeterReading = (dr["A4CLMeterReading"] == DBNull.Value) ? 0 : int.Parse(dr["A4CLMeterReading"].ToString()); tonnerRequest.Remarks = dr["Remarks"].ToString(); tonnerRequest.isCustomerEntry = bool.Parse(dr["IsCustomerEntry"].ToString()); tonnerRequest.CallStatusId = (dr["CallStatus"] == DBNull.Value) ? 0 : int.Parse(dr["CallStatus"].ToString()); } } con.Close(); } } return(tonnerRequest); } }
private static int Approval_Save(Entity.Service.TonerRequest tonnerRequest, DataTable dtTonnerRequest, bool isLowYield) { int approvalResponse = 0; Business.Service.ServiceBook objServiceBook = new Business.Service.ServiceBook(); Entity.Service.ServiceBook serviceBook = new Entity.Service.ServiceBook(); using (DataTable dtApproval = new DataTable()) { dtApproval.Columns.Add("ApprovalId"); dtApproval.Columns.Add("ServiceBookId"); dtApproval.Columns.Add("ItemId"); dtApproval.Columns.Add("ApprovalStatus"); dtApproval.Columns.Add("IsLowYield"); dtApproval.Columns.Add("CallStatus"); dtApproval.Columns.Add("RespondBy"); dtApproval.Columns.Add("Comment"); dtApproval.Columns.Add("RequisiteQty"); foreach (TonerIdQuantity item in tonnerRequest.SpareIds) { DataRow drApprovalItem = dtApproval.NewRow(); drApprovalItem["ApprovalId"] = 0; drApprovalItem["ServiceBookId"] = dtTonnerRequest.Rows[0]["ServiceBookId"].ToString(); drApprovalItem["ItemId"] = item.TonerId; drApprovalItem["ApprovalStatus"] = (isLowYield) ? (int)ApprovalStatus.None : (int)ApprovalStatus.Approved; drApprovalItem["IsLowYield"] = isLowYield; drApprovalItem["CallStatus"] = (isLowYield) ? (int)CallStatusType.TonerOpenForApproval : (int)CallStatusType.TonerRequestInQueue; drApprovalItem["RespondBy"] = string.Empty; drApprovalItem["Comment"] = (isLowYield) ? "NEED TONER APPROVAL" : "AUTO APPROVED"; drApprovalItem["RequisiteQty"] = item.Quantity; dtApproval.Rows.Add(drApprovalItem); dtApproval.AcceptChanges(); } serviceBook.ApprovalItems = dtApproval; serviceBook.ApprovalItems.AcceptChanges(); approvalResponse = objServiceBook.Service_ServiceBookDetailsApproval_Save(serviceBook); return(approvalResponse); } }
public static DataSet Service_TonnerRequest_GetAllMinimal(Entity.Service.TonerRequest tonerRequest) { using (DataSet response = new DataSet()) { using (SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["constr"].ToString())) { using (SqlCommand cmd = new SqlCommand()) { cmd.Parameters.AddWithValue("@CallStatus", tonerRequest.MultipleCallStatusFilter); if (tonerRequest.AssignEngineer == 0) { cmd.Parameters.AddWithValue("@AssignEngineer", DBNull.Value); } else { cmd.Parameters.AddWithValue("@AssignEngineer", tonerRequest.AssignEngineer); } cmd.InsertPaging(tonerRequest, tonerRequest.TonerRequestId); cmd.Connection = con; cmd.CommandType = CommandType.StoredProcedure; cmd.CommandText = "usp_Service_TonnerRequest_GetAllMinimal"; using (SqlDataAdapter da = new SqlDataAdapter(cmd)) { if (con.State == ConnectionState.Closed) { con.Open(); } da.Fill(response); con.Close(); } } return(response); } } }
protected void btnSubmit_Click(object sender, EventArgs e) { if (ComplainValidation()) { Business.Service.TonerRequest objTonnerRequest = new Business.Service.TonerRequest(); Entity.Service.TonerRequest tonnerRequest = new Entity.Service.TonerRequest(); Business.Service.ServiceBook objServiceBook = new Business.Service.ServiceBook(); Entity.Service.ServiceBook serviceBook = new Entity.Service.ServiceBook(); foreach (GridViewRow gvr in gvPurchase.Rows) { if (((CheckBox)gvr.FindControl("chk")).Checked) { tonnerRequest.CustomerPurchaseId = int.Parse(gvPurchase.DataKeys[gvr.RowIndex].Values[0].ToString()); serviceBook.CustomerPurchaseId = int.Parse(gvPurchase.DataKeys[gvr.RowIndex].Values[0].ToString()); } } tonnerRequest.CustomerId = int.Parse(HttpContext.Current.User.Identity.Name.Split('|')[(int)Constants.Customer.ID]);; tonnerRequest.RequestNo = ""; tonnerRequest.RequestDateTime = DateTime.Now; tonnerRequest.isCustomerEntry = true; tonnerRequest.CallStatusId = (int)CallStatusType.TonerRequestInQueue; if (txtA3BWMeterReading.Text.Trim() == string.Empty) { tonnerRequest.A3BWMeterReading = null; } else { tonnerRequest.A3BWMeterReading = int.Parse(txtA3BWMeterReading.Text.Trim()); } if (txtA4BWMeterReading.Text.Trim() == string.Empty) { tonnerRequest.A4BWMeterReading = null; } else { tonnerRequest.A4BWMeterReading = int.Parse(txtA4BWMeterReading.Text.Trim()); } if (txtA3CLMeterReading.Text.Trim() == string.Empty) { tonnerRequest.A3CLMeterReading = null; } else { tonnerRequest.A3CLMeterReading = int.Parse(txtA3CLMeterReading.Text.Trim()); } if (txtA4CLMeterReading.Text.Trim() == string.Empty) { tonnerRequest.A4CLMeterReading = null; } else { tonnerRequest.A4CLMeterReading = int.Parse(txtA4CLMeterReading.Text.Trim()); } tonnerRequest.Remarks = txtRequest.Text.Trim(); tonnerRequest.CreatedBy = int.Parse(HttpContext.Current.User.Identity.Name.Split('|')[(int)Constants.Customer.ID]); foreach (GridViewRow toner in gvTonner.Rows) { if (((CheckBox)toner.FindControl("chk1")).Checked) { tonnerRequest.SpareIds.Add(new TonerIdQuantity { TonerId = long.Parse(gvTonner.DataKeys[toner.RowIndex].Values[0].ToString()), Quantity = int.Parse(((TextBox)toner.FindControl("txtRequisiteQty")).Text) }); } } if (txtA3BWMeterReading.Text.Trim() == string.Empty) { serviceBook.A3BWMeterReading = null; } else { serviceBook.A3BWMeterReading = int.Parse(txtA3BWMeterReading.Text.Trim()); } if (txtA4BWMeterReading.Text.Trim() == string.Empty) { serviceBook.A4BWMeterReading = null; } else { serviceBook.A4BWMeterReading = int.Parse(txtA4BWMeterReading.Text.Trim()); } if (txtA3CLMeterReading.Text.Trim() == string.Empty) { serviceBook.A3CLMeterReading = null; } else { serviceBook.A3CLMeterReading = int.Parse(txtA3CLMeterReading.Text.Trim()); } if (txtA4CLMeterReading.Text.Trim() == string.Empty) { serviceBook.A4CLMeterReading = null; } else { serviceBook.A4CLMeterReading = int.Parse(txtA4CLMeterReading.Text.Trim()); } DataTable dtTonnerRequest = objTonnerRequest.Service_TonerRequest_Save(tonnerRequest); bool isTonerLowYield = objTonnerRequest.Service_TonerLowYieldCheck(tonnerRequest); int meterUpdateResponse = objServiceBook.Service_MeterReading_Update(serviceBook); if (dtTonnerRequest.Rows.Count > 0 && meterUpdateResponse > 0) { string message = "Toner request received. Your request no : " + dtTonnerRequest.Rows[0]["TonnerRequestNo"].ToString() + ". "; /* Checking whether machine is in contract or not*/ Business.Service.Contract objContract = new Business.Service.Contract(); int approvalResponse = Approval_Save(tonnerRequest, dtTonnerRequest, isTonerLowYield); if (!objContract.Service_MachineIsInContractCheck(CustomerPurchaseId) || isTonerLowYield) //Out of Contract AND Low Yield { if (approvalResponse > 0) { //Appending low toner warning message += Server.HtmlDecode("<span style='color:red'>Warning: Your request is under verification</span>"); //SentNotification(objServiceBook, dtTonnerRequest); } } ResetControls(dtTonnerRequest); Message.IsSuccess = true; Message.Text = message; } else { Message.IsSuccess = false; Message.Text = "Sorry! we can not receive your request. Please try again."; } Message.Show = true; } }
public static bool Service_TonerLowYieldCheck(Entity.Service.TonerRequest tonerRequest) { bool retValue = false; foreach (TonerIdQuantity toner in tonerRequest.SpareIds) { using (DataTable dt = new DataTable()) { using (SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["constr"].ToString())) { using (SqlCommand sqlCommand = new SqlCommand()) { sqlCommand.Connection = con; sqlCommand.CommandType = CommandType.StoredProcedure; sqlCommand.CommandText = "usp_Service_TonerLowYieldCheck"; sqlCommand.Parameters.AddWithValue("@CustomerPurchaseId", tonerRequest.CustomerPurchaseId); sqlCommand.Parameters.AddWithValue("@TonerId", toner.TonerId); sqlCommand.Parameters.AddWithValue("@TonerQuantity", toner.Quantity); if (tonerRequest.A3BWMeterReading == null) { sqlCommand.Parameters.AddWithValue("@A3BWCurrentMeterReading", 0); } else { sqlCommand.Parameters.AddWithValue("@A3BWCurrentMeterReading", tonerRequest.A3BWMeterReading); } if (tonerRequest.A4BWMeterReading == null) { sqlCommand.Parameters.AddWithValue("@A4BWCurrentMeterReading", 0); } else { sqlCommand.Parameters.AddWithValue("@A4BWCurrentMeterReading", tonerRequest.A4BWMeterReading); } if (tonerRequest.A3CLMeterReading == null) { sqlCommand.Parameters.AddWithValue("@A3CLCurrentMeterReading", 0); } else { sqlCommand.Parameters.AddWithValue("@A3CLCurrentMeterReading", tonerRequest.A3CLMeterReading); } if (tonerRequest.A4CLMeterReading == null) { sqlCommand.Parameters.AddWithValue("@A4CLCurrentMeterReading", 0); } else { sqlCommand.Parameters.AddWithValue("@A4CLCurrentMeterReading", tonerRequest.A4CLMeterReading); } if (con.State == ConnectionState.Closed) { con.Open(); } using (SqlDataAdapter da = new SqlDataAdapter(sqlCommand)) { da.Fill(dt); } con.Close(); } } if (dt != null && dt.Rows.Count > 0 && dt.Rows[0]["Flag"].ToString() == "1") { retValue = true; break; } } } return(retValue); }
public static DataTable Service_TonerRequest_Save(Entity.Service.TonerRequest tonerRequest) { using (DataTable response = new DataTable()) { using (SqlConnection sqlConnection = new SqlConnection(ConfigurationManager.ConnectionStrings["constr"].ToString())) { using (SqlCommand sqlCommand = new SqlCommand()) { sqlCommand.Connection = sqlConnection; sqlCommand.CommandText = "usp_Service_TonnerRequest_Save"; sqlCommand.CommandType = CommandType.StoredProcedure; sqlCommand.Parameters.AddWithValue("@TonnerRequestId", tonerRequest.TonerRequestId); sqlCommand.Parameters.AddWithValue("@CustomerPurchaseId", tonerRequest.CustomerPurchaseId); sqlCommand.Parameters.AddWithValue("@RequestDateTime", tonerRequest.RequestDateTime); if (tonerRequest.A3BWMeterReading == null) { sqlCommand.Parameters.AddWithValue("@A3BWMeterReading", DBNull.Value); } else { sqlCommand.Parameters.AddWithValue("@A3BWMeterReading", tonerRequest.A3BWMeterReading); } if (tonerRequest.A4BWMeterReading == null) { sqlCommand.Parameters.AddWithValue("@A4BWMeterReading", DBNull.Value); } else { sqlCommand.Parameters.AddWithValue("@A4BWMeterReading", tonerRequest.A4BWMeterReading); } if (tonerRequest.A3CLMeterReading == null) { sqlCommand.Parameters.AddWithValue("@A3CLMeterReading", DBNull.Value); } else { sqlCommand.Parameters.AddWithValue("@A3CLMeterReading", tonerRequest.A3CLMeterReading); } if (tonerRequest.A4CLMeterReading == null) { sqlCommand.Parameters.AddWithValue("@A4CLMeterReading", DBNull.Value); } else { sqlCommand.Parameters.AddWithValue("@A4CLMeterReading", tonerRequest.A4CLMeterReading); } sqlCommand.Parameters.AddWithValue("@SpareId", tonerRequest.SpareIds.FirstOrDefault().TonerId); //Passing the first spareId sqlCommand.Parameters.AddWithValue("@TonerQty", tonerRequest.SpareIds.FirstOrDefault().Quantity); //Passing the first spareId if (tonerRequest.Remarks == "") { sqlCommand.Parameters.AddWithValue("@Remarks", DBNull.Value); } else { sqlCommand.Parameters.AddWithValue("@Remarks", tonerRequest.Remarks); } sqlCommand.Parameters.AddWithValue("@IsCustomerEntry", tonerRequest.isCustomerEntry); sqlCommand.Parameters.AddWithValue("@CallStatus", tonerRequest.CallStatusId); sqlCommand.Parameters.AddWithValue("@CreatedBy", tonerRequest.CreatedBy); if (sqlConnection.State == ConnectionState.Closed) { sqlConnection.Open(); } using (SqlDataAdapter da = new SqlDataAdapter(sqlCommand)) { da.Fill(response); sqlConnection.Close(); } //Inserting rest spareIds if (response.Rows.Count > 0)//Valid response { for (int spareIndex = 1; spareIndex < tonerRequest.SpareIds.Count(); spareIndex++) { sqlCommand.Parameters.Clear(); sqlCommand.CommandText = "usp_Service_TonerRequestValue_Save"; sqlCommand.CommandType = CommandType.StoredProcedure; sqlCommand.Parameters.AddWithValue("@TonerRequestValueId", tonerRequest.TonerRequestValueId); sqlCommand.Parameters.AddWithValue("@TonerRequestId", response.Rows[0]["TonnerRequestId"].ToString()); sqlCommand.Parameters.AddWithValue("@TonerId", tonerRequest.SpareIds[spareIndex].TonerId); sqlCommand.Parameters.AddWithValue("@TonerQty", tonerRequest.SpareIds[spareIndex].Quantity); if (sqlConnection.State == ConnectionState.Closed) { sqlConnection.Open(); } sqlCommand.ExecuteNonQuery(); } } sqlConnection.Close(); } } return(response); } }
public static DataSet Service_TonnerRequest_GetAll(Entity.Service.TonerRequest tonerRequest) { using (DataSet response = new DataSet()) { using (SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["constr"].ToString())) { using (SqlCommand cmd = new SqlCommand()) { if (tonerRequest.TonerRequestId == 0) { cmd.Parameters.AddWithValue("@TonerRequestId", DBNull.Value); } else { cmd.Parameters.AddWithValue("@TonerRequestId", tonerRequest.TonerRequestId); } if (tonerRequest.RequestNo == "") { cmd.Parameters.AddWithValue("@RequestNo", string.Empty); } else { cmd.Parameters.AddWithValue("@RequestNo", tonerRequest.RequestNo); } if (string.IsNullOrEmpty(tonerRequest.CustomerName)) { cmd.Parameters.AddWithValue("@CustomerName", DBNull.Value); } else { cmd.Parameters.AddWithValue("@CustomerName", tonerRequest.CustomerName); } if (tonerRequest.ProductId == 0) { cmd.Parameters.AddWithValue("@ProductId_FK", DBNull.Value); } else { cmd.Parameters.AddWithValue("@ProductId_FK", tonerRequest.ProductId); } if (tonerRequest.RequestFromDateTime == DateTime.MinValue) { cmd.Parameters.AddWithValue("@RequestFromDateTime", DBNull.Value); } else { cmd.Parameters.AddWithValue("@RequestFromDateTime", tonerRequest.RequestFromDateTime); } if (tonerRequest.RequestToDateTime == DateTime.MinValue) { cmd.Parameters.AddWithValue("@RequestToDateTime", DBNull.Value); } else { cmd.Parameters.AddWithValue("@RequestToDateTime", tonerRequest.RequestToDateTime); } if (string.IsNullOrEmpty(tonerRequest.MultipleCallStatusFilter)) { if (tonerRequest.CallStatusId == 0) { cmd.Parameters.AddWithValue("@CallStatus", DBNull.Value); } else { cmd.Parameters.AddWithValue("@CallStatus", tonerRequest.CallStatusId); } } else { cmd.Parameters.AddWithValue("@CallStatus", tonerRequest.MultipleCallStatusFilter); } if (tonerRequest.AssignEngineer == 0) { cmd.Parameters.AddWithValue("@AssignEngineer", DBNull.Value); } else { cmd.Parameters.AddWithValue("@AssignEngineer", tonerRequest.AssignEngineer); } cmd.InsertPaging(tonerRequest, tonerRequest.TonerRequestId); cmd.Connection = con; cmd.CommandType = CommandType.StoredProcedure; cmd.CommandText = "usp_Service_TonnerRequest_GetAll"; using (SqlDataAdapter da = new SqlDataAdapter(cmd)) { if (con.State == ConnectionState.Closed) { con.Open(); } da.Fill(response); con.Close(); } } return(response); } } }