private void InitcboUserGroup() { cCommon oCommon = new cCommon(); string strMessage = string.Empty, strCriteria = string.Empty; string strCode = cboUserGroup.SelectedValue; DataSet ds = new DataSet(); DataTable dt = new DataTable(); strCriteria = " Select * from user_group Order by user_group_name "; if (oCommon.SEL_SQL(strCriteria, ref ds, ref strMessage)) { dt = ds.Tables[0]; cboUserGroup.Items.Clear(); cboUserGroup.Items.Add(new ListItem("---- กรุณาเลือกข้อมูล ----", "")); int i; for (i = 0; i <= dt.Rows.Count - 1; i++) { cboUserGroup.Items.Add(new ListItem(dt.Rows[i]["user_group_name"].ToString(), dt.Rows[i]["user_group_code"].ToString())); } if (cboUserGroup.Items.FindByValue(strCode) != null) { cboUserGroup.SelectedIndex = -1; cboUserGroup.Items.FindByValue(strCode).Selected = true; } } }
private void InitcboBudgetType() { cCommon oCommon = new cCommon(); string strMessage = string.Empty, strCriteria = string.Empty; string strCode = cboBudget_type.SelectedValue; DataSet ds = new DataSet(); DataTable dt = new DataTable(); strCriteria = " Select * from general where g_type = 'budget_type' and g_code <> 'M' Order by g_sort "; if (oCommon.SEL_SQL(strCriteria, ref ds, ref strMessage)) { dt = ds.Tables[0]; cboBudget_type.Items.Clear(); int i; cboBudget_type.Items.Add(new ListItem("--- เลือกทั้งหมด ---", "")); for (i = 0; i <= dt.Rows.Count - 1; i++) { cboBudget_type.Items.Add(new ListItem(dt.Rows[i]["g_name"].ToString(), dt.Rows[i]["g_code"].ToString())); } if (cboBudget_type.Items.FindByValue(strCode) != null) { cboBudget_type.SelectedIndex = -1; cboBudget_type.Items.FindByValue(strCode).Selected = true; } } }
private void InitcboLot_to() { cCommon oCommon = new cCommon(); string strMessage = string.Empty, strCriteria = string.Empty; string strLot = cboLot_to.SelectedValue; DataSet ds = new DataSet(); DataTable dt = new DataTable(); strCriteria = " and budget_money_year = '" + BudgetYear + "' and budget_type='" + this.BudgetType + "' " + " and degree_code = '" + MyBudgetTransferHead.degree_code_to + "' " + " and major_code = '" + MyBudgetTransferHead.major_code_to + "' " + " and budget_plan_code = '" + MyBudgetTransferHead.budget_plan_code_to + "' "; var strSql = " select lot_code , lot_name from view_Budget_money_major " + " where 1=1 " + strCriteria + " group by lot_code , lot_name "; if (oCommon.SEL_SQL(strSql, ref ds, ref strMessage)) { dt = ds.Tables[0]; cboLot_to.Items.Clear(); cboLot_to.Items.Add(new ListItem("---- กรุณาเลือกข้อมูล ----", "")); int i; for (i = 0; i <= dt.Rows.Count - 1; i++) { cboLot_to.Items.Add(new ListItem(dt.Rows[i]["lot_name"].ToString(), dt.Rows[i]["lot_code"].ToString())); } if (cboLot_to.Items.FindByValue(strLot) != null) { cboLot_to.SelectedIndex = -1; cboLot_to.Items.FindByValue(strLot).Selected = true; } } InitcboItem_group_to(); }
protected bool SetUserProfile(string strUserName, ref string _strError) { bool booResult = false; cPerson objPerson = new cPerson(); cUser objUser = new cUser(); DataTable dt = new DataTable(); DataSet ds = new DataSet(); string strCriteria; string strMessage = string.Empty; strCriteria = " And person_id='" + strUserName + "' "; objUser.SP_PERSON_USER_SEL(strCriteria, ref ds, ref strMessage); dt = ds.Tables[0]; if (dt.Rows.Count > 0) { base.PersonId = strUserName; this.UserGroupList = Helper.CStr(dt.Rows[0]["user_group_list"]); string[] ArrUserGroup = this.UserGroupList.Split(','); if (ArrUserGroup.Length > 1) { cCommon oCommon = new cCommon(); strMessage = string.Empty; strCriteria = string.Empty; ds = new DataSet(); dt = new DataTable(); string struser_group_list = string.Empty; foreach (string str in ArrUserGroup) { struser_group_list += "'" + str + "',"; } if (struser_group_list.Length > 0) { struser_group_list = struser_group_list.Substring(0, struser_group_list.Length - 1); } strCriteria = " Select * from user_group where user_group_code in (" + struser_group_list + ")"; if (oCommon.SEL_SQL(strCriteria, ref ds, ref strMessage)) { dt = ds.Tables[0]; rptUserGroupSelect.DataSource = dt; rptUserGroupSelect.DataBind(); WarningModal.Show(); } } else { this.UserGroupCode = ArrUserGroup[0].Trim(); //this.UserGroupCode = "001"; GotoUserMode(this.UserGroupCode); } booResult = true; } else { _strError = "ไม่พบผู้ใช้งานนี้"; } return(booResult); }
private int GetApproveCount() { string strCriteria = string.Empty; string strCriteriaLoan = string.Empty; cCommon oCommon = new cCommon(); DataSet ds = new DataSet(); DataTable dt = new DataTable(); DataTable dtLoan = new DataTable(); #region Criteria strCriteria = "Select count(1) as item_count from view_ef_open_detail_approve "; strCriteria += " Where (person_code = '" + base.PersonCode + "') "; strCriteria += " And (approve_status = 'P') "; strCriteria += " And (approve_head_status not in ('C','W')) "; strCriteria += " And (select count(1) from ef_open_detail_approve " + " Where ef_open_detail_approve.open_head_id= view_ef_open_detail_approve.open_head_id " + " And view_ef_open_detail_approve.approve_level > ef_open_detail_approve.approve_level " + " And ef_open_detail_approve.approve_status <> 'A') = 0 "; strCriteriaLoan = "Select count(1) as item_count from view_ef_loan_detail_approve "; strCriteriaLoan += " Where (person_code = '" + base.PersonCode + "') "; strCriteriaLoan += " And (approve_status = 'P') "; strCriteriaLoan += " And (loan_status not in ('C','W')) "; strCriteriaLoan += " And (select count(1) from ef_loan_detail_approve " + " Where ef_loan_detail_approve.loan_id= view_ef_loan_detail_approve.loan_id " + " And view_ef_loan_detail_approve.approve_level > ef_loan_detail_approve.approve_level " + " And ef_loan_detail_approve.approve_status <> 'A') = 0 "; #endregion try { if (oCommon.SEL_SQL(strCriteria, ref ds, ref _strMessage)) { dt = ds.Tables[0]; } if (oCommon.SEL_SQL(strCriteriaLoan, ref ds, ref _strMessage)) { dtLoan = ds.Tables[0]; } var result = Helper.CInt(dt.Rows[0]["item_count"]) + Helper.CInt(dtLoan.Rows[0]["item_count"]); return(result); } catch (Exception ex) { lblError.Text = ex.Message.ToString(); } return(0); }
private bool CheckClosePayment() { cCommon oCommon = new cCommon(); string strMessage = string.Empty, strCriteria = string.Empty; DataSet ds = new DataSet(); DataTable dt = new DataTable(); strCriteria = " Select * from general where g_type = 'close_payment' "; if (oCommon.SEL_SQL(strCriteria, ref ds, ref strMessage)) { dt = ds.Tables[0]; if (dt.Rows.Count == 0) { return(false); } else { return(Helper.CStr(dt.Rows[0]["g_code"]) == "Y"); } } return(false); }
protected string myLink() { string strIDBase64 = string.Empty; try { Byte[] bytesToEncode; // bytesToEncode = System.Text.Encoding.UTF8.GetBytes("3570100525491"); bytesToEncode = System.Text.Encoding.UTF8.GetBytes(base.PersonID); strIDBase64 = Convert.ToBase64String(bytesToEncode); } catch { } string strSal1 = "0.00"; string strSal2 = "0.00"; cCommon oCommon = new cCommon(); DataSet ds = new DataSet(); DataSet ds2 = new DataSet(); string strMessage = string.Empty; string strSQL = string.Empty; strSQL = "Select Sum(item_debit) as item_debit_sum from [view_person_item] where person_code ='" + base.PersonCode + "' and [item_name] like '%ปจต%' "; oCommon.SEL_SQL(strSQL, ref ds, ref strMessage); if (ds.Tables[0].Rows.Count > 0) { strSal1 = Helper.CStr(ds.Tables[0].Rows[0]["item_debit_sum"], "0.00"); } strSQL = "Select Sum(item_debit) as item_debit_sum from [view_person_item] where person_code ='" + base.PersonCode + "' and [item_name] like '%ตอบแทน%' "; oCommon.SEL_SQL(strSQL, ref ds2, ref strMessage); if (ds2.Tables[0].Rows.Count > 0) { strSal2 = Helper.CStr(ds2.Tables[0].Rows[0]["item_debit_sum"], "0.00"); } string strURL = "http://personnel.mju.ac.th/form_salary/index.php?pid=" + strIDBase64 + "&sal1=" + strSal1 + "&sal2=" + strSal2 + ""; return(strURL); }
private void BindGridItem() { cCommon oCommon = new cCommon(); string strMessage = string.Empty, strCriteria = string.Empty; DataSet ds = new DataSet(); DataTable dt = new DataTable(); try { strCriteria = " Select * from user_group Order by user_group_code "; if (oCommon.SEL_SQL(strCriteria, ref ds, ref strMessage)) { dt = ds.Tables[0]; GridView1.DataSource = dt; GridView1.DataBind(); } } catch (Exception ex) { lblError.Text = ex.Message; } }
public string GetConfigItem(string strCode) { string strMessage = string.Empty; var objCommon = new cCommon(); var ds = new DataSet(); DataTable table; var strCriteria = "Select [dbo].[getConfigCode]('" + strCode + "') as Code"; objCommon.SEL_SQL(strCriteria, ref ds, ref strMessage); if (ds.Tables.Count <= 0) { return(string.Empty); } table = ds.Tables[0]; if (table.Rows.Count > 0) { var rowArray = table.Rows[0]; return(rowArray["Code"].ToString()); } return(string.Empty); }
private bool saveRecvDetail() { bool blnResult = false; cBudget_receive oBudget_receive = new cBudget_receive(); cBudget_money oBudget_money = new cBudget_money(); cCommon oCommon = new cCommon(); var ds = new DataSet(); DataTable dt = null; var major_director_code = string.Empty; oCommon.SEL_SQL("select g_code from General where g_type = 'main_director_code'", ref ds, ref _strMessage); dt = ds.Tables[0]; if (dt.Rows.Count > 0) { major_director_code = "M" + cboYear.SelectedValue.Substring(2, 2) + dt.Rows[0]["g_code"].ToString(); } _strCriteria = " and budget_money_doc = '" + txtbudget_money_doc.Text + "' "; _strCriteria += " and major_code in (select '" + major_director_code + "' union all select '" + cboMajor.SelectedValue + "') "; var listBudget_major = oBudget_money.GETMONEYDETAILS(_strCriteria); if (listBudget_major != null) { List <Budget_receive_detail> listBudget_receive_detail = new List <Budget_receive_detail>(); try { decimal detail_contribute = 0; foreach (var row in listBudget_major) { if (row.major_code == major_director_code) { detail_contribute = decimal.Parse(txtdeduct_total_reduce_director.Value.ToString()); } else { detail_contribute = decimal.Parse(txtdeduct_total_remain.Value.ToString()); } listBudget_receive_detail.Add(new Budget_receive_detail { budget_receive_doc = txtbudget_receive_doc.Text, budget_money_major_id = row.budget_money_major_id, budget_receive_detail_contribute = detail_contribute, c_created_by = Session["username"].ToString(), c_updated_by = Session["username"].ToString() }); } DeleteRecvDetail(txtbudget_receive_doc.Text); if (listBudget_receive_detail.Any()) { foreach (var major in listBudget_receive_detail) { oBudget_receive.SP_BUDGET_RECEIVE_DETAIL_INS(major); } } blnResult = true; } catch (Exception ex) { if (ex.Message.Contains("duplicate key")) { MsgBox("ข้อมูลซ้ำโปรดตรวจสอบ"); } else { lblError.Text = ex.Message.ToString(); } } finally { oBudget_receive.Dispose(); } } return(blnResult); }