private void InitcboItem_group() { cItem_group oItem_group = new cItem_group(); string strMessage = string.Empty, strCriteria = string.Empty; string strItem_group_code = string.Empty; string strYear = cboYear.SelectedValue; strItem_group_code = cboItem_group.SelectedValue; DataSet ds = new DataSet(); DataTable dt = new DataTable(); strCriteria = " and Item_group_year = '" + strYear + "' and c_active='Y' "; if (oItem_group.SP_ITEM_GROUP_SEL(strCriteria, ref ds, ref strMessage)) { dt = ds.Tables[0]; cboItem_group.Items.Clear(); cboItem_group.Items.Add(new ListItem("---- เลือกข้อมูลทั้งหมด ----", "")); int i; for (i = 0; i <= dt.Rows.Count - 1; i++) { cboItem_group.Items.Add(new ListItem(dt.Rows[i]["Item_group_name"].ToString(), dt.Rows[i]["Item_group_code"].ToString())); } if (cboItem_group.Items.FindByValue(strItem_group_code) != null) { cboItem_group.SelectedIndex = -1; cboItem_group.Items.FindByValue(strItem_group_code).Selected = true; } } }
private void InitcboItem_group() { cItem_group oItem_group = new cItem_group(); string strMessage = string.Empty, strCriteria = string.Empty, strItem_group_code = string.Empty; var strYear = ViewState["year"].ToString(); strItem_group_code = cboItem_group.SelectedValue; int i; DataSet ds = new DataSet(); DataTable dt = new DataTable(); strCriteria = "and item_group_code IN (Select item_group_code from view_Budget_money_detail where budget_plan_code = '" + ViewState["budget_plan_code"].ToString() + "') "; if (oItem_group.SP_ITEM_GROUP_SEL(strCriteria, ref ds, ref strMessage)) { dt = ds.Tables[0]; cboItem_group.Items.Clear(); cboItem_group.Items.Add(new ListItem("---- เลือกข้อมูลทั้งหมด ----", "")); for (i = 0; i <= dt.Rows.Count - 1; i++) { cboItem_group.Items.Add(new ListItem(dt.Rows[i]["Item_group_name"].ToString(), dt.Rows[i]["Item_group_code"].ToString())); } if (cboItem_group.Items.FindByValue(strItem_group_code) != null) { cboItem_group.SelectedIndex = -1; cboItem_group.Items.FindByValue(strItem_group_code).Selected = true; } } }
protected void GridView1_RowDeleting(object sender, GridViewDeleteEventArgs e) { string strMessage = string.Empty; string strCheck = string.Empty; string strScript = string.Empty; string strUpdatedBy = Session["username"].ToString(); Label lblitem_group_code = (Label)GridView1.Rows[e.RowIndex].FindControl("lblitem_group_code"); cItem_group oItem_group = new cItem_group(); try { if (!oItem_group.SP_ITEM_GROUP_DEL(lblitem_group_code.Text, "N", strUpdatedBy, ref strMessage)) { lblError.Text = strMessage; } } catch (Exception ex) { lblError.Text = ex.Message.ToString(); } finally { oItem_group.Dispose(); } BindGridView(0); }
protected void GridView1_RowDeleting(object sender, GridViewDeleteEventArgs e) { string strMessage = string.Empty; string strCheck = string.Empty; string strScript = string.Empty; string strUpdatedBy = Session["username"].ToString(); Label lblitem_group_code = (Label)GridView1.Rows[e.RowIndex].FindControl("lblitem_group_code"); cItem_group oItem_group = new cItem_group(); try { oItem_group.SP_ITEM_GROUP_DEL(lblitem_group_code.Text); } catch (Exception ex) { if (ex.Message.Contains(" REFERENCE constraint")) { MsgBox("ไม่สามารถลบข้อมูลได้เนื่องจากมีการนำไปใช้ในระบบแล้ว"); } else { lblError.Text = ex.Message.ToString(); } } finally { oItem_group.Dispose(); } BindGridView(0); }
//private void InitcboItem_group() //{ // cItem_group oItem_group = new cItem_group(); // string strMessage = string.Empty, // strCriteria = string.Empty, // strItem_group_code = string.Empty; // strItem_group_code = cboItem_group.SelectedValue; // int i; // DataSet ds = new DataSet(); // DataTable dt = new DataTable(); // strCriteria = " and c_active='Y' "; // strCriteria += " and item_group_year = '" + cboYear.SelectedValue + "' "; // strCriteria += " and budget_type = '" + this.BudgetType + "' "; // if (oItem_group.SP_SEL_item_group(strCriteria, ref ds, ref strMessage)) // { // dt = ds.Tables[0]; // cboItem_group.Items.Clear(); // cboItem_group.Items.Add(new ListItem("---- เลือกข้อมูลทั้งหมด ----", "")); // for (i = 0; i <= dt.Rows.Count - 1; i++) // { // cboItem_group.Items.Add(new ListItem(dt.Rows[i]["Item_group_name"].ToString(), dt.Rows[i]["Item_group_code"].ToString())); // } // if (cboItem_group.Items.FindByValue(strItem_group_code) != null) // { // cboItem_group.SelectedIndex = -1; // cboItem_group.Items.FindByValue(strItem_group_code).Selected = true; // } // } //} private void InitcboItem_group() { cItem_group oItem_group = new cItem_group(); string strMessage = string.Empty, strCriteria = string.Empty, strItem_group_code = string.Empty; string strlot_code = cboLot.SelectedValue; strItem_group_code = cboItem_group.SelectedValue; int i; DataSet ds = new DataSet(); DataTable dt = new DataTable(); //strCriteria = " and lot_code='" + strlot_code + "' and lot_code <> '' and budget_plan_code='" + txtbudget_plan_code.Text + "' "; strCriteria = " And lot_code='" + strlot_code + "' and lot_code <> '' and item_group_code <> '' "; strCriteria += " And item_year = '" + cboYear.SelectedValue + "' "; strCriteria += " And budget_type ='" + this.BudgetType + "' "; if (oItem_group.SP_BUDGET_ITEM_GROUP_SEL(strCriteria, ref ds, ref strMessage)) { dt = ds.Tables[0]; cboItem_group.Items.Clear(); cboItem_group.Items.Add(new ListItem("---- เลือกข้อมูลทั้งหมด ----", "")); for (i = 0; i <= dt.Rows.Count - 1; i++) { cboItem_group.Items.Add(new ListItem(dt.Rows[i]["budget_item_group_name"].ToString(), dt.Rows[i]["budget_item_group_code"].ToString())); } if (cboItem_group.Items.FindByValue(strItem_group_code) != null) { cboItem_group.SelectedIndex = -1; cboItem_group.Items.FindByValue(strItem_group_code).Selected = true; } } }
private void setData() { cItem_group oItem_group = new cItem_group(); DataSet ds = new DataSet(); string strMessage = string.Empty, strCriteria = string.Empty; string stritem_group_code = string.Empty, stritem_group_name = string.Empty, strYear = string.Empty, strC_active = string.Empty, strCreatedBy = string.Empty, strUpdatedBy = string.Empty, strCreatedDate = string.Empty, strUpdatedDate = string.Empty; try { strCriteria = " and item_group_code = '" + ViewState["item_group_code"].ToString() + "' "; if (!oItem_group.SP_SEL_item_group(strCriteria, ref ds, ref strMessage)) { lblError.Text = strMessage; } else { if (ds.Tables[0].Rows.Count > 0) { #region get Data stritem_group_code = ds.Tables[0].Rows[0]["item_group_code"].ToString(); stritem_group_name = ds.Tables[0].Rows[0]["item_group_name"].ToString(); strYear = ds.Tables[0].Rows[0]["item_group_year"].ToString(); strC_active = ds.Tables[0].Rows[0]["c_active"].ToString(); strCreatedBy = ds.Tables[0].Rows[0]["c_created_by"].ToString(); strUpdatedBy = ds.Tables[0].Rows[0]["c_updated_by"].ToString(); strCreatedDate = ds.Tables[0].Rows[0]["d_created_date"].ToString(); strUpdatedDate = ds.Tables[0].Rows[0]["d_updated_date"].ToString(); #endregion #region set Control txtitem_group_code.Text = stritem_group_code; txtitem_group_name.Text = stritem_group_name; txtyear.Text = strYear; if (strC_active.Equals("Y")) { chkStatus.Checked = true; } else { chkStatus.Checked = false; } txtUpdatedBy.Text = strUpdatedBy; txtUpdatedDate.Text = strUpdatedDate; #endregion } } } catch (Exception ex) { lblError.Text = ex.Message.ToString(); } }
private void setData() { cItem_group oItem_group = new cItem_group(); try { _strCriteria = " and item_group_code = '" + ViewState["item_group_code"].ToString() + "' "; var item_group = oItem_group.GET(_strCriteria); if (item_group != null) { #region set Control txtitem_group_code.Text = item_group.item_group_code; txtitem_group_name.Text = item_group.item_group_name; if (cboItem_type.Items.FindByValue(item_group.item_group_type) != null) { cboItem_type.SelectedIndex = -1; cboItem_type.Items.FindByValue(item_group.item_group_type).Selected = true; } InitcboYear(); if (cboYear.Items.FindByValue(item_group.item_group_year) != null) { cboYear.SelectedIndex = -1; cboYear.Items.FindByValue(item_group.item_group_year).Selected = true; } InitcboLot(); if (cboLot_code.Items.FindByValue(item_group.lot_code) != null) { cboLot_code.SelectedIndex = -1; cboLot_code.Items.FindByValue(item_group.lot_code).Selected = true; } if (item_group.c_active.Equals("Y")) { txtitem_group_name.ReadOnly = false; txtitem_group_name.CssClass = "textbox"; chkStatus.Checked = true; } else { txtitem_group_name.ReadOnly = true; txtitem_group_name.CssClass = "textboxdis"; chkStatus.Checked = false; } cboYear.Enabled = false; cboYear.CssClass = "textboxdis"; txtUpdatedBy.Text = item_group.c_updated_by; txtUpdatedDate.Text = item_group.d_updated_date.ToString(); #endregion } } catch (Exception ex) { lblError.Text = ex.Message.ToString(); } }
private void InitcboItem_group() { cItem_group oItem_group = new cItem_group(); string strMessage = string.Empty, strCriteria = string.Empty, strItem_group_code = string.Empty; var strYear = string.Empty; if (this.BudgetType == "B") { strYear = ((DataSet)Application["xmlconfig"]).Tables["default"].Rows[0]["yearnow"].ToString(); } else { strYear = ((DataSet)Application["xmlconfig"]).Tables["default"].Rows[0]["yearnow2"].ToString(); } strItem_group_code = cboItem_group.SelectedValue; int i; DataSet ds = new DataSet(); DataTable dt = new DataTable(); strCriteria = "and item_group_year='" + strYear + "' and lot_code = '" + cboLot.SelectedValue + "' "; if (!string.IsNullOrEmpty(cboLot.SelectedValue)) { strCriteria += " and lot_code = '" + cboLot.SelectedValue + "' "; } if (oItem_group.SP_ITEM_GROUP_SEL(strCriteria, ref ds, ref strMessage)) { dt = ds.Tables[0]; cboItem_group.Items.Clear(); cboItem_group.Items.Add(new ListItem("---- กรุณาเลือกข้อมูล ----", "")); for (i = 0; i <= dt.Rows.Count - 1; i++) { cboItem_group.Items.Add(new ListItem(dt.Rows[i]["Item_group_name"].ToString(), dt.Rows[i]["Item_group_code"].ToString())); } if (cboItem_group.Items.FindByValue(strItem_group_code) != null) { cboItem_group.SelectedIndex = -1; cboItem_group.Items.FindByValue(strItem_group_code).Selected = true; } } }
private void BindGridView() { cItem_group oitem_group = new cItem_group(); DataSet ds = new DataSet(); string strMessage = string.Empty; string strCriteria = string.Empty; string stritem_group_code = string.Empty; string stritem_group_name = string.Empty; string strScript = string.Empty; string stritem_group_year = string.Empty; stritem_group_code = txtitem_group_code.Text.Replace("'", "''").Trim(); stritem_group_name = txtitem_group_name.Text.Replace("'", "''").Trim(); stritem_group_year = txtitem_group_year.Text.Replace("'", "''").Trim();; if (!stritem_group_code.Equals("")) { strCriteria = strCriteria + " And (item_group_code like '%" + stritem_group_code + "%') "; } if (!stritem_group_name.Equals("")) { strCriteria = strCriteria + " And (item_group_name like '%" + stritem_group_name + "%')"; } if (!stritem_group_year.Equals("")) { strCriteria = strCriteria + " And (item_group_year = '" + stritem_group_year + "') "; } strCriteria = strCriteria + " And (c_active ='Y') "; try { if (oitem_group.SP_SEL_item_group(strCriteria, ref ds, ref strMessage)) { if (ds.Tables[0].Rows.Count == 1) { stritem_group_code = ds.Tables[0].Rows[0]["item_group_code"].ToString(); stritem_group_name = ds.Tables[0].Rows[0]["item_group_name"].ToString(); if (!ViewState["show"].ToString().Equals("1")) { strScript = "window.parent.frames['iframeShow" + (int.Parse(ViewState["show"].ToString()) - 1) + "'].document.getElementById('" + ViewState["ctrl1"].ToString() + "').value='" + stritem_group_code + "';\n " + "window.parent.frames['iframeShow" + (int.Parse(ViewState["show"].ToString()) - 1) + "'].document.getElementById('" + ViewState["ctrl2"].ToString() + "').value='" + stritem_group_name + "';\n" + "ClosePopUp('" + ViewState["show"].ToString() + "');"; } else { strScript = "window.parent.document.forms[0]." + ViewState["ctrl1"].ToString() + ".value='" + stritem_group_code + "';\n " + "window.parent.document.forms[0]." + ViewState["ctrl2"].ToString() + ".value='" + stritem_group_name + "';\n" + "ClosePopUp('" + ViewState["show"].ToString() + "');"; } ScriptManager.RegisterStartupScript(Page, Page.GetType(), "close", strScript, true); } else { ds.Tables[0].DefaultView.Sort = ViewState["sort"] + " " + ViewState["direction"]; GridView1.DataSource = ds.Tables[0]; GridView1.DataBind(); } } else { lblError.Text = strMessage; } } catch (Exception ex) { lblError.Text = ex.Message.ToString(); } finally { oitem_group.Dispose(); ds.Dispose(); } }
private bool saveData() { bool blnResult = false; bool blnDup = false; string strScript = string.Empty; cItem_group oItem_group = new cItem_group(); DataSet ds = new DataSet(); try { #region set Data var item_group = new Item_group() { item_group_code = txtitem_group_code.Text.Trim(), item_group_name = txtitem_group_name.Text, item_group_year = cboYear.SelectedItem.Value, lot_code = cboLot_code.SelectedItem.Value, item_group_type = cboItem_type.SelectedItem.Value, c_active = chkStatus.Checked ? "Y" : "N", c_created_by = Session["username"].ToString(), c_updated_by = Session["username"].ToString() }; #endregion if (ViewState["mode"].ToString().ToLower().Equals("edit")) { #region edit if (!blnDup) { if (oItem_group.SP_ITEM_GROUP_UPD(item_group, ref _strMessage)) { blnResult = true; } else { lblError.Text = _strMessage.ToString(); } } else { ScriptManager.RegisterStartupScript(Page, Page.GetType(), "frMainPage", strScript, true); } #endregion } else { #region check dup string strCheckDup = string.Empty; strCheckDup = " and item_group_name = '" + item_group.item_group_name + "' and item_group_year = '" + item_group.item_group_year + "' "; if (!oItem_group.SP_ITEM_GROUP_SEL(strCheckDup, ref ds, ref _strMessage)) { lblError.Text = _strMessage.ToString(); } else { if (ds.Tables[0].Rows.Count > 0) { strScript = "alert(\"ไม่สามารถเพิ่มข้อมูล เนื่องจากข้อมูล " + item_group.item_group_name + " ปี " + item_group.item_group_year + " ซ้ำ\");\n"; blnDup = true; } } #endregion #region insert if (!blnDup) { if (oItem_group.SP_ITEM_GROUP_INS(item_group, ref _strMessage)) { string strGetcode = " and item_group_name = '" + item_group.item_group_name.Trim() + "' and item_group_year = '" + item_group.item_group_year + "' "; if (!oItem_group.SP_ITEM_GROUP_SEL(strGetcode, ref ds, ref _strMessage)) { lblError.Text = _strMessage; } if (ds.Tables[0].Rows.Count > 0) { item_group.item_group_code = ds.Tables[0].Rows[0]["item_group_code"].ToString(); } ViewState["item_group_code"] = item_group.item_group_code; blnResult = true; } else { lblError.Text = _strMessage.ToString(); } } else { ScriptManager.RegisterStartupScript(Page, Page.GetType(), "frMainPage", strScript, true); } #endregion } } catch (Exception ex) { lblError.Text = ex.Message.ToString(); } finally { oItem_group.Dispose(); } return(blnResult); }
private void BindGridView(int nPageNo) { cItem_group oItem_group = new cItem_group(); DataSet ds = new DataSet(); string strMessage = string.Empty; string strCriteria = string.Empty; string stritem_group_code = string.Empty; string stritem_group_name = string.Empty; string strActive = string.Empty; string stritem_group_year = string.Empty; stritem_group_code = txtitem_group_code.Text.Replace("'", "''").Trim(); stritem_group_name = txtitem_group_name.Text.Replace("'", "''").Trim(); stritem_group_year = cboYear.SelectedValue; if (!stritem_group_code.Equals("0")) { strCriteria = strCriteria + " And (item_group_code like '%" + stritem_group_code + "%') "; } if (!stritem_group_name.Equals("0")) { strCriteria = strCriteria + " And (item_group_name like '%" + stritem_group_name + "%')"; } if (!stritem_group_year.Equals("0")) { strCriteria = strCriteria + " And (item_group_year = '" + stritem_group_year + "') "; } if (RadioActive.Checked) { strCriteria = strCriteria + " And (c_active ='Y') "; } else if (RadioCancel.Checked) { strCriteria = strCriteria + " And (c_active ='N') "; } try { if (!oItem_group.SP_SEL_item_group(strCriteria, ref ds, ref strMessage)) { lblError.Text = strMessage; } else { try { GridView1.PageIndex = nPageNo; txthTotalRecord.Value = ds.Tables[0].Rows.Count.ToString(); ds.Tables[0].DefaultView.Sort = ViewState["sort"] + " " + ViewState["direction"]; GridView1.DataSource = ds.Tables[0]; GridView1.DataBind(); } catch { GridView1.PageIndex = 0; txthTotalRecord.Value = ds.Tables[0].Rows.Count.ToString(); ds.Tables[0].DefaultView.Sort = ViewState["sort"] + " " + ViewState["direction"]; GridView1.DataSource = ds.Tables[0]; GridView1.DataBind(); } } } catch (Exception ex) { lblError.Text = ex.Message.ToString(); } finally { oItem_group.Dispose(); ds.Dispose(); if (GridView1.Rows.Count > 0) { GridView1.TopPagerRow.Visible = true; } } }
private void setData() { cItem_group oItem_group = new cItem_group(); DataSet ds = new DataSet(); string strMessage = string.Empty, strCriteria = string.Empty; string stritem_group_code = string.Empty, stritem_group_name = string.Empty, strlot_code = string.Empty, strYear = string.Empty, strItem_group_order = string.Empty, strC_active = string.Empty, strCreatedBy = string.Empty, strUpdatedBy = string.Empty, strCreatedDate = string.Empty, strUpdatedDate = string.Empty; try { strCriteria = " and item_group_code = '" + ViewState["item_group_code"].ToString() + "' "; if (!oItem_group.SP_SEL_item_group(strCriteria, ref ds, ref strMessage)) { lblError.Text = strMessage; } else { if (ds.Tables[0].Rows.Count > 0) { #region get Data stritem_group_code = ds.Tables[0].Rows[0]["item_group_code"].ToString(); stritem_group_name = ds.Tables[0].Rows[0]["item_group_name"].ToString(); strlot_code = ds.Tables[0].Rows[0]["lot_code"].ToString(); strYear = ds.Tables[0].Rows[0]["item_group_year"].ToString(); strItem_group_order = ds.Tables[0].Rows[0]["item_group_order"].ToString(); strC_active = ds.Tables[0].Rows[0]["c_active"].ToString(); strCreatedBy = ds.Tables[0].Rows[0]["c_created_by"].ToString(); strUpdatedBy = ds.Tables[0].Rows[0]["c_updated_by"].ToString(); strCreatedDate = ds.Tables[0].Rows[0]["d_created_date"].ToString(); strUpdatedDate = ds.Tables[0].Rows[0]["d_updated_date"].ToString(); #endregion #region set Control txtitem_group_code.Text = stritem_group_code; txtitem_group_name.Text = stritem_group_name; InitcboYear(); if (cboYear.Items.FindByValue(strYear) != null) { cboYear.SelectedIndex = -1; cboYear.Items.FindByValue(strYear).Selected = true; } InitcboLot(); if (cboLot_code.Items.FindByValue(strlot_code) != null) { cboLot_code.SelectedIndex = -1; cboLot_code.Items.FindByValue(strlot_code).Selected = true; } if (strC_active.Equals("Y")) { txtitem_group_name.ReadOnly = false; txtitem_group_name.CssClass = "textbox"; chkStatus.Checked = true; } else { txtitem_group_name.ReadOnly = true; txtitem_group_name.CssClass = "textboxdis"; chkStatus.Checked = false; } cboYear.Enabled = false; cboYear.CssClass = "textboxdis"; txtUpdatedBy.Text = strUpdatedBy; txtUpdatedDate.Text = strUpdatedDate; txtitem_group_order.Value = strItem_group_order; #endregion } } } catch (Exception ex) { lblError.Text = ex.Message.ToString(); } }