protected void Page_Load(object sender, EventArgs e) { if (Session["USER_NAME"] != null) { string requestedFile = Path.GetFileName(Request.Path); OracleConnection conn = new OracleConnection(strConnString); conn.Open(); string makeSQL = " SELECT NUPP.IS_PAGE_ACTIVE, NUPP.IS_ADD_ACTIVE, NUPP.IS_EDIT_ACTIVE, NUPP.IS_DELETE_ACTIVE, NUPP.IS_VIEW_ACTIVE FROM NRC_USER_PAGE_PERMISSION NUPP LEFT JOIN NRC_USER_PAGES NUP ON NUP.USER_PAGE_ID = NUPP.USER_PAGE_ID WHERE NUPP.USER_ID = '" + Session["USER_ID"] + "' AND NUP.IS_ACTIVE = 'Enable' AND NUP.PAGE_URL = '" + requestedFile + "' "; cmdl = new OracleCommand(makeSQL); oradata = new OracleDataAdapter(cmdl.CommandText, conn); dt = new DataTable(); oradata.Fill(dt); RowCount = dt.Rows.Count; for (int i = 0; i < RowCount; i++) { IS_PAGE_ACTIVE = dt.Rows[i]["IS_PAGE_ACTIVE"].ToString(); IS_ADD_ACTIVE = dt.Rows[i]["IS_ADD_ACTIVE"].ToString(); IS_EDIT_ACTIVE = dt.Rows[i]["IS_EDIT_ACTIVE"].ToString(); IS_DELETE_ACTIVE = dt.Rows[i]["IS_DELETE_ACTIVE"].ToString(); IS_VIEW_ACTIVE = dt.Rows[i]["IS_VIEW_ACTIVE"].ToString(); } if (IS_PAGE_ACTIVE == "Enable") { if (!IsPostBack) { DataTable dtCatID = new DataTable(); DataSet dc = new DataSet(); string makeDropDownCatSQL = " SELECT ITEM_ID, ITEM_NAME || ' - ' || ITEM_CODE AS ITEM_NAME FROM MF_ITEM WHERE IS_ACTIVE = 'Enable' ORDER BY ITEM_ID ASC"; dc = ExecuteBySqlString(makeDropDownCatSQL); dtCatID = (DataTable)dc.Tables[0]; DropDownItemID.DataSource = dtCatID; DropDownItemID.DataValueField = "ITEM_ID"; DropDownItemID.DataTextField = "ITEM_NAME"; DropDownItemID.DataBind(); DropDownItemID.Items.Insert(0, new ListItem("Select Item", "0")); BtnUpdate.Attributes.Add("aria-disabled", "false"); BtnUpdate.Attributes.Add("class", "btn btn-success disabled"); BtnDelete.Attributes.Add("aria-disabled", "false"); BtnDelete.Attributes.Add("class", "btn btn-danger disabled"); DropDownItemID.Focus(); Display(); alert_box.Visible = false; } IsLoad = false; } else { Response.Redirect("~/PagePermissionError.aspx"); } } else { Response.Redirect("~/Default.aspx"); } }
public void TextItemWeight_TextChanged(object sender, EventArgs e) { int ItemID = Convert.ToInt32(DropDownItemID.Text); if (ItemID != 0) { int SubItemID = Convert.ToInt32(DropDownSubItemID.Text); string ItemWeightCheck = TextItemWeight.Text; string MatchPattern = "([0-9.]+)"; if (ItemWeightCheck != null) { if (Regex.IsMatch(ItemWeightCheck, MatchPattern)) { alert_box.Visible = false; OracleConnection conn = new OracleConnection(strConnString); conn.Open(); string makeSQL = " select nvl(sum(ITEM_WEIGHT),0) AS ITEM_WEIGHT from PF_PURCHASE_JW where ITEM_ID = '" + ItemID + "' AND SUB_ITEM_ID = '" + SubItemID + "' "; cmdl = new OracleCommand(makeSQL); oradata = new OracleDataAdapter(cmdl.CommandText, conn); dt = new DataTable(); oradata.Fill(dt); RowCount = dt.Rows.Count; double FinalStock = 0.00; double ItemWeight = Convert.ToDouble(TextItemWeight.Text); for (int i = 0; i < RowCount; i++) { FinalStock = Convert.ToDouble(dt.Rows[i]["ITEM_WEIGHT"].ToString()); } if (ItemWeight <= FinalStock) { CheckItemWeight.Text = "<label class='control-label'><i class='fa fa fa-check'></i> This Material is available</label>"; CheckItemWeight.ForeColor = System.Drawing.Color.Green; EntryDate.Focus(); BtnAdd.Attributes.Add("aria-disabled", "true"); BtnAdd.Attributes.Add("class", "btn btn-primary active"); } else { CheckItemWeight.Text = "<label class='control-label'><i class='fa fa-times-circle-o'></i> This Material is not available. Available Material is <span class='badge bg-yellow'>" + FinalStock + "</span> metric ton (MT)</label>"; CheckItemWeight.ForeColor = System.Drawing.Color.Red; TextItemWeight.Focus(); BtnAdd.Attributes.Add("aria-disabled", "false"); BtnAdd.Attributes.Add("class", "btn btn-primary disabled"); } } else { CheckItemWeight.Text = "<label class='control-label'><i class='fa fa-hand-o-left'></i> Enter Material Weight</label>"; CheckItemWeight.ForeColor = System.Drawing.Color.Red; TextItemWeight.Focus(); BtnAdd.Attributes.Add("aria-disabled", "false"); BtnAdd.Attributes.Add("class", "btn btn-primary disabled"); } } } else { alert_box.Visible = false; TextItemWeight.Text = ""; CheckItemWeight.Text = ""; DropDownItemID.Focus(); } }
public void TextItemRate_Changed(object sender, EventArgs e) { if (TextItemRate.Text != "" && TextItemWeight.Text != "") { int ItemID = Convert.ToInt32(DropDownItemID.Text); if (ItemID != 0) { int SubItemID = Convert.ToInt32(DropDownSubItemID.Text); string ItemWeightCheck = TextItemWeight.Text; string MatchPattern = "([0-9.]+)"; if (ItemWeightCheck != null) { if (Regex.IsMatch(ItemWeightCheck, MatchPattern)) { alert_box.Visible = false; OracleConnection conn = new OracleConnection(strConnString); conn.Open(); string makeSQL = " select nvl(sum(ITEM_WEIGHT),0) AS FINAL_STOCK_WT from PF_PRODUCTION_JW where ITEM_ID = '" + ItemID + "' "; cmdl = new OracleCommand(makeSQL); oradata = new OracleDataAdapter(cmdl.CommandText, conn); dt = new DataTable(); oradata.Fill(dt); RowCount = dt.Rows.Count; double FinalStock = 0.00; double ItemWeightF = Convert.ToDouble(TextItemWeight.Text); for (int i = 0; i < RowCount; i++) { FinalStock = Convert.ToDouble(dt.Rows[i]["FINAL_STOCK_WT"].ToString()); } if (ItemWeightF <= FinalStock) { CheckItemWeight.Text = "<label class='control-label'><i class='fa fa fa-check'></i> This Material is available</label>"; CheckItemWeight.ForeColor = System.Drawing.Color.Green; TextItemRate.Focus(); BtnAdd.Attributes.Add("aria-disabled", "true"); BtnAdd.Attributes.Add("class", "btn btn-primary active"); BtnUpdate.Attributes.Add("aria-disabled", "true"); BtnUpdate.Attributes.Add("class", "btn btn-success active"); } else { CheckItemWeight.Text = "<label class='control-label'><i class='fa fa-times-circle-o'></i> This Material is not available for Sale from Job Work (Purchase). Available Material is <span class='badge bg-yellow'>" + FinalStock + "</span> metric ton (MT)</label>"; CheckItemWeight.ForeColor = System.Drawing.Color.Red; TextItemWeight.Focus(); BtnAdd.Attributes.Add("aria-disabled", "false"); BtnAdd.Attributes.Add("class", "btn btn-primary disabled"); BtnUpdate.Attributes.Add("aria-disabled", "false"); BtnUpdate.Attributes.Add("class", "btn btn-success disabled"); } } else { CheckItemWeight.Text = "<label class='control-label'><i class='fa fa-hand-o-left'></i> Enter Material Weight</label>"; CheckItemWeight.ForeColor = System.Drawing.Color.Red; TextItemWeight.Focus(); BtnAdd.Attributes.Add("aria-disabled", "false"); BtnAdd.Attributes.Add("class", "btn btn-primary disabled"); } } } else { alert_box.Visible = false; CheckItemWeight.Text = ""; DropDownItemID.Focus(); } double ItemRate = Convert.ToDouble(TextItemRate.Text); double ItemWeight = Convert.ToDouble(TextItemWeight.Text); double ItemAmount = ItemRate * ItemWeight; string ItemAmountNew = Math.Round(decimal.Parse(ItemAmount.ToString()), 0).ToString(); double ItemAmountNewD = Convert.ToDouble(ItemAmountNew); TextItemAmount.Text = ItemAmountNewD.ToString("0.00"); double VatPercent = Convert.ToDouble(DropDownVatID.SelectedItem.Text); double VatPercentAmt = (ItemAmount * VatPercent) / 100; TextVatAmount.Text = VatPercentAmt.ToString("0.00"); EntryDate.Focus(); } }