private void InitcboDirector() { cDirector oDirector = new cDirector(); string strMessage = string.Empty, strCriteria = string.Empty; string strDirector_code = string.Empty; string strYear = cboYear.SelectedValue; strDirector_code = cboDirector.SelectedValue; if (Request.Form[strPrefixCtr + "cboDirector"] != null) { strDirector_code = Request.Form[strPrefixCtr + "cboDirector"].ToString(); } DataSet ds = new DataSet(); DataTable dt = new DataTable(); strCriteria = " and Director_year = '" + strYear + "' and c_active='Y' "; if (oDirector.SP_SEL_DIRECTOR(strCriteria, ref ds, ref strMessage)) { dt = ds.Tables[0]; cboDirector.Items.Clear(); cboDirector.Items.Add(new ListItem("---- เลือกข้อมูลทั้งหมด ----", "")); int i; for (i = 0; i <= dt.Rows.Count - 1; i++) { cboDirector.Items.Add(new ListItem(dt.Rows[i]["Director_name"].ToString(), dt.Rows[i]["Director_code"].ToString())); } if (cboDirector.Items.FindByValue(strDirector_code) != null) { cboDirector.SelectedIndex = -1; cboDirector.Items.FindByValue(strDirector_code).Selected = true; } } }
private void InitcboDirector() { cDirector oDirector = new cDirector(); string strMessage = string.Empty, strCriteria = string.Empty; string strDirector_code = string.Empty; string strYear = ((DataSet)Application["xmlconfig"]).Tables["default"].Rows[0]["yearnow"].ToString(); strDirector_code = cboDirector.SelectedValue; DataSet ds = new DataSet(); DataTable dt = new DataTable(); strCriteria = " and director_year = '" + strYear + "' and c_active='Y' "; if (DirectorLock == "Y") { strCriteria += " and substring(director_code,4,2) = substring('" + DirectorCode + "',4,2) "; } if (oDirector.SP_SEL_DIRECTOR(strCriteria, ref ds, ref strMessage)) { dt = ds.Tables[0]; cboDirector.Items.Clear(); cboDirector.Items.Add(new ListItem("---- เลือกข้อมูลทั้งหมด ----", "")); int i; for (i = 0; i <= dt.Rows.Count - 1; i++) { cboDirector.Items.Add(new ListItem(dt.Rows[i]["director_name"].ToString(), dt.Rows[i]["director_code"].ToString())); } if (cboDirector.Items.FindByValue(strDirector_code) != null) { cboDirector.SelectedIndex = -1; cboDirector.Items.FindByValue(strDirector_code).Selected = true; } InitcboUnit(); } }
private void setData() { cDirector oDirector = new cDirector(); DataSet ds = new DataSet(); string strMessage = string.Empty, strCriteria = string.Empty; string strdirector_code = string.Empty, strdirector_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 director_code = '" + ViewState["director_code"].ToString() + "' "; if (!oDirector.SP_SEL_DIRECTOR(strCriteria, ref ds, ref strMessage)) { lblError.Text = strMessage; } else { if (ds.Tables[0].Rows.Count > 0) { #region get Data strdirector_code = ds.Tables[0].Rows[0]["director_code"].ToString(); strdirector_name = ds.Tables[0].Rows[0]["director_name"].ToString(); strYear = ds.Tables[0].Rows[0]["director_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 txtdirector_code.Text = strdirector_code; txtdirector_name.Text = strdirector_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(); } }
public DataTable GetDataDirector(string strYear) { cDirector oDirector = new cDirector(); string strMessage = string.Empty, strCriteria = string.Empty; string strDirector_code = string.Empty, strDirector_name = string.Empty; DataSet ds = new DataSet(); DataTable dt = new DataTable(); strCriteria = " and Director_year = '" + strYear + "' and c_active='Y' "; if (oDirector.SP_SEL_DIRECTOR(strCriteria, ref ds, ref strMessage)) { dt = ds.Tables[0]; } return(dt); }
private void InitcboDirector() { cDirector oDirector = new cDirector(); string strMessage = string.Empty, strCriteria = string.Empty; string strDirector_code = string.Empty; string strYear = cboYear.SelectedValue; strDirector_code = cboDirector.SelectedValue; DataSet ds = new DataSet(); DataTable dt = new DataTable(); strCriteria = " and director_year = '" + strYear + "' and c_active='Y' "; if (DirectorLock == "Y") { strCriteria += " and director_code = '" + DirectorCode + "' "; } if (this.BudgetType == "R") { strCriteria = strCriteria + " and budget_type <> 'B' "; } else { strCriteria = strCriteria + " and budget_type <> 'R' "; } if (oDirector.SP_SEL_DIRECTOR(strCriteria, ref ds, ref strMessage)) { dt = ds.Tables[0]; cboDirector.Items.Clear(); cboDirector.Items.Add(new ListItem("--- เลือกทั้งหมด ---", "")); int i; for (i = 0; i <= dt.Rows.Count - 1; i++) { cboDirector.Items.Add(new ListItem(dt.Rows[i]["director_name"].ToString(), dt.Rows[i]["director_code"].ToString())); } if (cboDirector.Items.FindByValue(strDirector_code) != null) { cboDirector.SelectedIndex = -1; cboDirector.Items.FindByValue(strDirector_code).Selected = true; } InitcboUnit(); } }
private void BindgridDirector() { cDirector oDirector = new cDirector(); DataSet ds = new DataSet(); string strMessage = string.Empty; string strCriteria = string.Empty; string strYear = string.Empty; strYear = cboYear.SelectedValue; strCriteria = " And (director_year='" + strYear + "') "; try { #region Diector if (!oDirector.SP_SEL_DIRECTOR(strCriteria, ref ds, ref strMessage)) { lblError.Text = strMessage; } else { ds.Tables[0].DefaultView.Sort = ViewState["sort"] + " " + ViewState["direction"]; gridDirector.DataSource = ds.Tables[0]; gridDirector.DataBind(); } #endregion } catch (Exception ex) { lblError.Text = ex.Message.ToString(); } finally { oDirector.Dispose(); ds.Dispose(); } }
private void setData() { cDirector oDirector = new cDirector(); DataSet ds = new DataSet(); string strMessage = string.Empty, strCriteria = string.Empty; string strdirector_code = string.Empty, strdirector_name = string.Empty, strdirector_sign_name = string.Empty, strsign_position = string.Empty, strdirector_order = string.Empty, strYear = string.Empty, strC_active = string.Empty, strBudget_type = string.Empty, strCreatedBy = string.Empty, strUpdatedBy = string.Empty, strCreatedDate = string.Empty, strUpdatedDate = string.Empty; try { strCriteria = " and director_code = '" + ViewState["director_code"].ToString() + "' "; if (!oDirector.SP_SEL_DIRECTOR(strCriteria, ref ds, ref strMessage)) { lblError.Text = strMessage; } else { if (ds.Tables[0].Rows.Count > 0) { #region get Data strdirector_code = ds.Tables[0].Rows[0]["director_code"].ToString(); strdirector_name = ds.Tables[0].Rows[0]["director_name"].ToString(); strdirector_sign_name = Helper.CStr(ds.Tables[0].Rows[0]["director_sign_name"]); strsign_position = Helper.CStr(ds.Tables[0].Rows[0]["sign_position"]); strYear = ds.Tables[0].Rows[0]["director_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(); strBudget_type = ds.Tables[0].Rows[0]["budget_type"].ToString(); strdirector_order = ds.Tables[0].Rows[0]["director_order"].ToString(); #endregion #region set Control txtdirector_code.Text = strdirector_code; txtdirector_name.Text = strdirector_name; txtdirector_sign_name.Text = strdirector_sign_name; txtsign_position.Text = strsign_position; txtdirector_order.Value = strdirector_order; InitcboYear(); if (cboYear.Items.FindByValue(strYear) != null) { cboYear.SelectedIndex = -1; cboYear.Items.FindByValue(strYear).Selected = true; } if (strC_active.Equals("Y")) { txtdirector_name.ReadOnly = false; txtdirector_name.CssClass = "textbox"; chkStatus.Checked = true; } else { txtdirector_name.ReadOnly = true; txtdirector_name.CssClass = "textboxdis"; chkStatus.Checked = false; } InitcboBudgetType(); if (cboBudget_type.Items.FindByValue(strBudget_type) != null) { cboBudget_type.SelectedIndex = -1; cboBudget_type.Items.FindByValue(strBudget_type).Selected = true; } cboYear.Enabled = false; cboYear.CssClass = "textboxdis"; txtUpdatedBy.Text = strUpdatedBy; txtUpdatedDate.Text = strUpdatedDate; #endregion } } } catch (Exception ex) { lblError.Text = ex.Message.ToString(); } }
private bool saveData() { bool blnResult = false; bool blnDup = false; string strMessage = string.Empty; string strdirector_code = string.Empty, strdirector_year = string.Empty, strdirector_name = string.Empty, strdirector_sign_name = string.Empty, strdirector_sign_image = string.Empty, strsign_position = string.Empty, strActive = string.Empty, strCreatedBy = string.Empty, strUpdatedBy = string.Empty, strBudget_type = string.Empty; string strScript = string.Empty; cDirector oDirector = new cDirector(); DataSet ds = new DataSet(); try { #region set Data strdirector_code = txtdirector_code.Text.Trim(); strdirector_name = txtdirector_name.Text; strdirector_year = cboYear.SelectedItem.Value; strdirector_sign_name = txtdirector_sign_name.Text; strsign_position = txtsign_position.Text; strBudget_type = cboBudget_type.SelectedItem.Value; if (txtdirector_sign_image.Text.Length > 0) { strdirector_sign_image = MapPath("~/person_pic/" + txtdirector_sign_image.Text); } if (chkStatus.Checked == true) { strActive = "Y"; } else { strActive = "N"; } strCreatedBy = Session["username"].ToString(); strUpdatedBy = Session["username"].ToString(); #endregion if (ViewState["mode"].ToString().ToLower().Equals("edit")) { #region edit if (!blnDup) { if (strdirector_sign_image != "") { if (oDirector.SP_UPD_DIRECTOR(strdirector_code, strdirector_year, strdirector_name, strdirector_sign_name, strdirector_sign_image, strsign_position, txtdirector_order.Value.ToString(), strActive, strUpdatedBy, strBudget_type, ref strMessage)) { blnResult = true; } else { lblError.Text = strMessage.ToString(); } } else { if (oDirector.SP_UPD_NOIMAGE_DIRECTOR(strdirector_code, strdirector_year, strdirector_name, strdirector_sign_name, strsign_position, txtdirector_order.Value.ToString(), strActive, strUpdatedBy, strBudget_type, 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 director_name = '" + strdirector_name.Trim() + "' and director_year = '" + strdirector_year + "' "; if (!oDirector.SP_SEL_DIRECTOR(strCheckDup, ref ds, ref strMessage)) { lblError.Text = strMessage; } else { if (ds.Tables[0].Rows.Count > 0) { strScript = "alert(\"ไม่สามารถเพิ่มข้อมูล เนื่องจากข้อมูล " + strdirector_name.Trim() + " ปี " + strdirector_year.Trim() + " ซ้ำ\");\n"; blnDup = true; } } #endregion #region insert if (!blnDup) { if (oDirector.SP_INS_DIRECTOR(strdirector_year, strdirector_name, strdirector_sign_name, strdirector_sign_image, strsign_position, txtdirector_order.Value.ToString(), strActive, strCreatedBy, strBudget_type, ref strMessage)) { string strGetcode = " and director_name = '" + strdirector_name.Trim() + "' and director_year = '" + strdirector_year + "' "; if (!oDirector.SP_SEL_DIRECTOR(strGetcode, ref ds, ref strMessage)) { lblError.Text = strMessage; } if (ds.Tables[0].Rows.Count > 0) { strdirector_code = ds.Tables[0].Rows[0]["director_code"].ToString(); } ViewState["director_code"] = strdirector_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 { oDirector.Dispose(); } return(blnResult); }
private void BindGridView(int nPageNo) { cDirector oDirector = new cDirector(); DataSet ds = new DataSet(); string strMessage = string.Empty; string strCriteria = string.Empty; string strdirector_code = string.Empty; string strdirector_name = string.Empty; string strActive = string.Empty; string strdirector_year = string.Empty; strdirector_code = txtdirector_code.Text.Replace("'", "''").Trim(); strdirector_name = txtdirector_name.Text.Replace("'", "''").Trim(); strdirector_year = cboYear.SelectedValue; if (!strdirector_code.Equals("0")) { strCriteria = strCriteria + " And (director_code like '%" + strdirector_code + "%') "; } if (!strdirector_name.Equals("0")) { strCriteria = strCriteria + " And (director_name like '%" + strdirector_name + "%')"; } if (!strdirector_year.Equals("0")) { strCriteria = strCriteria + " And (director_year = '" + strdirector_year + "') "; } if (RadioActive.Checked) { strCriteria = strCriteria + " And (c_active ='Y') "; } else if (RadioCancel.Checked) { strCriteria = strCriteria + " And (c_active ='N') "; } try { if (!oDirector.SP_SEL_DIRECTOR(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 { oDirector.Dispose(); ds.Dispose(); if (GridView1.Rows.Count > 0) { GridView1.TopPagerRow.Visible = true; } } }