protected void Page_Load(object sender, EventArgs e) { try { if (string.IsNullOrEmpty((string)Session["CompanyId"]) && string.IsNullOrEmpty((string)Session["Username"])) { Response.Redirect("~/Default.aspx", false); } else { if (!IsPostBack) { //LoadBlankGrid(); if (Request.QueryString[0].Equals("VIEW")) { mlCode = Convert.ToInt32(Request.QueryString[1].ToString()); PurReq_BL = new PurchaseRequisition_BL(mlCode); FillCombo(); ViewRec("VIEW"); //DiabaleTextBoxes(MainPanel); } else if (Request.QueryString[0].Equals("MODIFY")) { mlCode = Convert.ToInt32(Request.QueryString[1].ToString()); PurReq_BL = new PurchaseRequisition_BL(mlCode); FillCombo(); ViewRec("MOD"); //EnabaleTextBoxes(MainPanel); } else if (Request.QueryString[0].Equals("INSERT")) { txtDate.Attributes.Add("readonly", "readonly"); txtDate.Text = System.DateTime.Now.ToString("dd MMM yyyy"); FillCombo(); dt2.Rows.Clear(); str = ""; //EnabaleTextBoxes(MainPanel); ddlMatReqNo.Enabled = false; ddlItemName.Enabled = false; dgvPurReqDet.Enabled = false; LoadBlankGrid(); } txtPerReqNo.Focus(); //LoadBlankGrid(); } } } catch (Exception Ex) { CommonClasses.SendError("Purchase Requisition", "Page_Load", Ex.Message); } }
protected void dgPurchaseRequsition_RowDeleting(object sender, GridViewDeleteEventArgs e) { try { if (CommonClasses.ValidRights(int.Parse(right.Substring(4, 1)), this, "For Delete")) { if (!ModifyLog(((Label)(dgPurchaseRequsition.Rows[e.RowIndex].FindControl("lblPRM_CODE"))).Text)) { string p_order = ((Label)(dgPurchaseRequsition.Rows[e.RowIndex].FindControl("lblPRM_CODE"))).Text; PerReq_BL = new PurchaseRequisition_BL(); PerReq_BL.PRM_CODE = Convert.ToInt32(p_order); if (PerReq_BL.Delete()) { CommonClasses.WriteLog("Purchase Requisition", "Delete", "Purchase Requisition", "", Convert.ToInt32(p_order), Convert.ToInt32(Session["CompanyId"]), Convert.ToInt32(Session["CompanyCode"]), (Session["Username"].ToString()), Convert.ToInt32(Session["UserCode"])); PanelMsg.Visible = true; lblmsg.Text = "Record Deleted Successfully"; ScriptManager.RegisterStartupScript(this, GetType(), "displayalertmessage", "Showalert();", true); LoadDetail(); } else { PanelMsg.Visible = true; lblmsg.Text = "Record Not Deleted.."; ScriptManager.RegisterStartupScript(this, GetType(), "displayalertmessage", "Showalert();", true); } } } else { PanelMsg.Visible = true; lblmsg.Text = "You have no rights to delete"; ScriptManager.RegisterStartupScript(this, GetType(), "displayalertmessage", "Showalert();", true); //ShowMessage("#Avisos", "You Have No Rights To Delete", CommonClasses.MSG_Erro); return; } } catch (Exception Ex) { CommonClasses.SendError("Purchase Requisition", "dgPurchaseRequsition_RowDeleting", Ex.Message); } }
bool SaveRec() { bool result = false; try { if (Request.QueryString[0].Equals("INSERT")) { PurReq_BL = new PurchaseRequisition_BL(); txtPerReqNo.Text = Numbering(); if (Setvalues()) { if (PurReq_BL.Save(dgvPurReqDet, "INSERT")) { string Code = CommonClasses.GetMaxId("Select Max(PRM_CODE) from PRUCHASE_REQUISITION_MASTER"); CommonClasses.WriteLog("Purchase Requsition", "Save", "Purchase Requisition", PurReq_BL.PRM_NO.ToString(), Convert.ToInt32(Code), Convert.ToInt32(Session["CompanyId"]), Convert.ToInt32(Session["CompanyCode"]), (Session["Username"].ToString()), Convert.ToInt32(Session["UserCode"])); result = true; Response.Redirect("~/Transactions/VIEW/ViewPurchaseRequisition.aspx", false); } else { if (PurReq_BL.Msg != "") { //ShowMessage("#Avisos", "Record Not Saved", CommonClasses.MSG_Warning); PurReq_BL.Msg = ""; PanelMsg.Visible = true; lblmsg.Text = "Record Not Saved"; ScriptManager.RegisterStartupScript(this, GetType(), "displayalertmessage", "Showalert();", true); } txtPerReqNo.Focus(); } } } else if (Request.QueryString[0].Equals("MODIFY")) { PurReq_BL = new PurchaseRequisition_BL(mlCode); if (Setvalues()) { if (PurReq_BL.Save(dgvPurReqDet, "UPDATE")) { CommonClasses.RemoveModifyLock("PRUCHASE_REQUISITION_MASTER", "MODIFY", "PRM_CODE", mlCode); CommonClasses.WriteLog("Purchase Requsition", "Update", "Purchase Requisition", PurReq_BL.PRM_NO.ToString(), Convert.ToInt32(mlCode), Convert.ToInt32(Session["CompanyId"]), Convert.ToInt32(Session["CompanyCode"]), (Session["Username"].ToString()), Convert.ToInt32(Session["UserCode"])); result = true; Response.Redirect("~/Transactions/VIEW/ViewPurchaseRequisition.aspx", false); } else { if (PurReq_BL.Msg != "") { //ShowMessage("#Avisos", "Record Not Saved", CommonClasses.MSG_Warning); PurReq_BL.Msg = ""; PanelMsg.Visible = true; lblmsg.Text = "Record Not Saved"; ScriptManager.RegisterStartupScript(this, GetType(), "displayalertmessage", "Showalert();", true); } txtPerReqNo.Focus(); } } } } catch (Exception ex) { CommonClasses.SendError("Purchase Requisition", "SaveRec", ex.Message); } return(result); }