public TemplateDrug setAccCashTransfer(DataTable dt) { TemplateDrug dgs1 = new TemplateDrug(); if (dt.Rows.Count > 0) { dgs1.temp_drug_id = dt.Rows[0][tdrug.temp_drug_id].ToString(); dgs1.temp_drug_name = dt.Rows[0][tdrug.temp_drug_name].ToString(); dgs1.drug_id = dt.Rows[0][tdrug.drug_id].ToString(); dgs1.active = dt.Rows[0][tdrug.active].ToString(); dgs1.remark = dt.Rows[0][tdrug.remark].ToString(); dgs1.date_create = dt.Rows[0][tdrug.date_create].ToString(); dgs1.date_modi = dt.Rows[0][tdrug.date_modi].ToString(); dgs1.date_cancel = dt.Rows[0][tdrug.date_cancel].ToString(); dgs1.user_create = dt.Rows[0][tdrug.user_create].ToString(); dgs1.user_modi = dt.Rows[0][tdrug.user_modi].ToString(); dgs1.user_cancel = dt.Rows[0][tdrug.user_cancel].ToString(); dgs1.usage_thai = dt.Rows[0][tdrug.usage_thai].ToString(); dgs1.usage_eng = dt.Rows[0][tdrug.usage_eng].ToString(); dgs1.qty = dt.Rows[0][tdrug.qty].ToString(); dgs1.staff_id = dt.Rows[0][tdrug.staff_id].ToString(); dgs1.sort1 = dt.Rows[0][tdrug.sort1].ToString(); } else { setAccCashTransfer(dgs1); } return(dgs1); }
public String update(TemplateDrug p, String userId) { String re = ""; String sql = ""; int chk = 0; chkNull(p); sql = "Update " + tdrug.table + " Set " + "" + tdrug.temp_drug_name + "= '" + p.temp_drug_name + "'" + "," + tdrug.active + "= '1'" + "," + tdrug.drug_id + "= '" + p.drug_id + "'" + "," + tdrug.remark + "= '" + p.remark.Replace("'", "''") + "'" + "," + tdrug.date_modi + "= now()" + "," + tdrug.user_modi + "= '" + userId + "@" + conn._IPAddress + "'" + "," + tdrug.usage_thai + "= '" + p.usage_thai.Replace("'", "''") + "'" + "," + tdrug.usage_eng + "= '" + p.usage_eng.Replace("'", "''") + "'" + "," + tdrug.qty + "= '" + p.qty + "'" + "," + tdrug.staff_id + "= '" + p.staff_id + "'" + "," + tdrug.sort1 + "= '" + p.sort1 + "'" + "Where " + tdrug.pkField + "='" + p.temp_drug_id + "'" ; try { re = conn.ExecuteNonQuery(conn.conn, sql); } catch (Exception ex) { sql = ex.Message + " " + ex.InnerException; } return(re); }
private void initConfig() { lFpf = new List <TemplateDrug>(); tdrug = new TemplateDrug(); tdrug.temp_drug_id = "temp_drug_id"; tdrug.temp_drug_name = "temp_drug_name"; tdrug.drug_id = "drug_id"; tdrug.usage_thai = "usage_thai"; tdrug.usage_eng = "usage_eng"; tdrug.qty = "qty"; tdrug.staff_id = "staff_id"; tdrug.sort1 = "sort1"; tdrug.active = "active"; tdrug.remark = "remark"; tdrug.date_create = "date_create"; tdrug.date_modi = "date_modi"; tdrug.date_cancel = "date_cancel"; tdrug.user_create = "user_create"; tdrug.user_modi = "user_modi"; tdrug.user_cancel = "user_cancel"; tdrug.table = "b_template_drug"; tdrug.pkField = "temp_drug_id"; }
public DataTable selectByTempDrugName(String stfidd) { TemplateDrug cop1 = new TemplateDrug(); DataTable dt = new DataTable(); String sql = "select distinct tdrug.temp_drug_name " + "From " + tdrug.table + " tdrug " + "Where tdrug." + tdrug.staff_id + " ='" + stfidd + "' and tdrug.active = '1' " + " "; dt = conn.selectData(conn.conn, sql); return(dt); }
private void BtnSave_Click(object sender, EventArgs e) { //throw new NotImplementedException(); Decimal qty = 0; if (cboTempDrugName.Text.Trim().Length <= 0) { //MessageBox.Show sep.SetError(cboTempDrugName, "Error"); stt.Show("ไม่มี ชื่อ Template", cboTempDrugName); return; } if (cboDrugName.Text.Trim().Length <= 0) { sep.SetError(cboDrugName, "Error"); stt.Show("ไม่มี ชื่อ Drug", cboDrugName); return; } if (!decimal.TryParse(txtQty.Text.Trim(), out qty) && qty <= 0) { sep.SetError(txtQty, "Error"); stt.Show("QTY error", txtQty); return; } if (txtEng.Text.Trim().Length <= 0) { sep.SetError(txtEng, "Error"); stt.Show("English error", txtEng); return; } if (txtThai.Text.Trim().Length <= 0) { sep.SetError(txtThai, "Error"); stt.Show("Thai error", txtThai); return; } TemplateDrug tdrug = new TemplateDrug(); tdrug = setTemplateDrug(); if (tdrug.temp_drug_id != null) { String re = ic.ivfDB.tdrugDB.insertTemplateDrug(tdrug, ic.userId); txtId.Value = re; setGrfTemplateDrug(stf.staff_id, cboTempDrugName.Text, grfDrug); ic.ivfDB.tdrugDB.setCboUsageT(cboTempDrugName, ""); txtId.Value = ""; txtThai.Value = ""; txtEng.Value = ""; txtQty.Value = "0"; txtRemark.Value = ""; cboDrugName.Text = ""; } }
public DataTable selectByPk1(String id) { TemplateDrug cop1 = new TemplateDrug(); DataTable dt = new DataTable(); String sql = "select tdrug.* " + "From " + tdrug.table + " tdrug " + //"Left Join f_patient_prefix pfx On stf.prefix_id = pfx.f_patient_prefix_id " + "Where tdrug." + tdrug.pkField + " ='" + id + "' " + "Order By tdrug.sort1 "; dt = conn.selectData(conn.conn, sql); return(dt); }
private void setControlTemplateDrug(String tempdrugid) { pageLoad = true; TemplateDrug tdrug = new TemplateDrug(); tdrug = ic.ivfDB.tdrugDB.selectByPk(tempdrugid); txtId.Value = tdrug.temp_drug_id; txtThai.Value = tdrug.usage_thai; txtEng.Value = tdrug.usage_eng; txtQty.Value = tdrug.qty; txtRemark.Value = tdrug.remark; ic.setC1Combo(cboDrugName, tdrug.drug_id); pageLoad = false; }
public String insertTemplateDrug(TemplateDrug p, String userId) { String re = ""; //chkNull(p); if (p.temp_drug_id.Equals("")) { re = insert(p, userId); } else { re = update(p, userId); } return(re); }
public void getlActCashTransfer(String stfid) { //lDept = new List<Position>(); lFpf.Clear(); DataTable dt = new DataTable(); dt = selectByTempDrugName(stfid); foreach (DataRow row in dt.Rows) { TemplateDrug itm1 = new TemplateDrug(); itm1.temp_drug_id = row[tdrug.temp_drug_id].ToString(); itm1.temp_drug_name = row[tdrug.temp_drug_name].ToString(); lFpf.Add(itm1); } }
public String insert(TemplateDrug p, String userId) { String re = ""; String sql = ""; //DataTable dt = new DataTable(); p.active = "1"; //p.ssdata_id = ""; int chk = 0; chkNull(p); sql = "Insert Into " + tdrug.table + " set " + "" + tdrug.temp_drug_name + "= '" + p.temp_drug_name + "'" + "," + tdrug.active + "= '1'" + "," + tdrug.drug_id + "= '" + p.drug_id + "'" + "," + tdrug.remark + "= '" + p.remark.Replace("'", "''") + "'" + "," + tdrug.date_create + "= now()" + "," + tdrug.date_modi + "= ''" + "," + tdrug.date_cancel + "= ''" + "," + tdrug.user_create + "= '" + userId + "@" + conn._IPAddress + "'" + "," + tdrug.user_modi + "= ''" + "," + tdrug.user_cancel + "= ''" + "," + tdrug.usage_thai + "= '" + p.usage_thai.Replace("'", "''") + "'" + "," + tdrug.usage_eng + "= '" + p.usage_eng.Replace("'", "''") + "'" + "," + tdrug.qty + "= '" + p.qty + "'" + "," + tdrug.staff_id + "= '" + p.staff_id + "'" + "," + tdrug.sort1 + "= '" + p.sort1 + "'" + ""; try { re = conn.ExecuteNonQuery(conn.conn, sql); //conn.Open(); // conn.comStore.ExecuteNonQuery(); // re = (String)conn.comStore.Parameters["row_no1"].Value; // //string retunvalue = (string)sqlcomm.Parameters["@b"].Value; } catch (Exception ex) { sql = ex.Message + " " + ex.InnerException; } finally { conn.conn.Close(); //conn.comStore.Dispose(); } return(re); }
private TemplateDrug setTemplateDrug() { TemplateDrug tdrug = new TemplateDrug(); decimal qty = 0; decimal.TryParse(txtQty.Text.Trim(), out qty); if (qty > 0) { tdrug.temp_drug_id = txtId.Text.Trim(); tdrug.active = "1"; tdrug.drug_id = cboDrugName.SelectedItem == null ? "" : ((ComboBoxItem)cboDrugName.SelectedItem).Value; tdrug.qty = qty.ToString(); tdrug.usage_eng = txtEng.Text.Trim(); tdrug.usage_thai = txtThai.Text.Trim(); tdrug.temp_drug_name = cboTempDrugName.Text; tdrug.staff_id = stf.staff_id; } return(tdrug); }
public TemplateDrug setAccCashTransfer(TemplateDrug dgs1) { dgs1.temp_drug_id = ""; dgs1.temp_drug_name = ""; dgs1.drug_id = ""; dgs1.active = ""; dgs1.remark = ""; dgs1.date_create = ""; dgs1.date_modi = ""; dgs1.date_cancel = ""; dgs1.user_create = ""; dgs1.user_modi = ""; dgs1.user_cancel = ""; dgs1.usage_thai = ""; dgs1.usage_eng = ""; dgs1.qty = ""; dgs1.staff_id = ""; dgs1.sort1 = ""; return(dgs1); }
private void chkNull(TemplateDrug p) { long chk = 0; decimal chk1 = 0; p.date_modi = p.date_modi == null ? "" : p.date_modi; p.date_cancel = p.date_cancel == null ? "" : p.date_cancel; p.date_create = p.date_create == null ? "" : p.date_create; p.user_create = p.user_create == null ? "" : p.user_create; p.user_modi = p.user_modi == null ? "" : p.user_modi; p.user_cancel = p.user_cancel == null ? "" : p.user_cancel; p.remark = p.remark == null ? "" : p.remark; p.temp_drug_name = p.temp_drug_name == null ? "" : p.temp_drug_name; p.usage_thai = p.usage_thai == null ? "" : p.usage_thai; p.usage_eng = p.usage_eng == null ? "" : p.usage_eng; p.qty = p.qty == null ? "" : p.qty; p.sort1 = p.sort1 == null ? "" : p.sort1; //p.remark = p.remark == null ? "" : p.remark; //p.deposit_amount = decimal.TryParse(p.deposit_amount, out chk1) ? chk1.ToString() : "0"; p.drug_id = long.TryParse(p.drug_id, out chk) ? chk.ToString() : "0"; p.staff_id = long.TryParse(p.staff_id, out chk) ? chk.ToString() : "0"; }