private void chkNull(EggStiDay p) { long chk = 0; p.date_modi = p.date_modi == null ? "" : p.date_modi; p.date_cancel = p.date_cancel == null ? "" : p.date_cancel; 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.day = long.TryParse(p.day, out chk) ? chk.ToString() : "0"; //p.e2 = long.TryParse(p.e2, out chk) ? chk.ToString() : "0"; //p.lt_ovary_1 = long.TryParse(p.lt_ovary_1, out chk) ? chk.ToString() : "0"; p.egg_sti_id = long.TryParse(p.egg_sti_id, out chk) ? chk.ToString() : "0"; p.date = p.date == null ? "0" : p.date; p.lh = p.lh == null ? "" : p.lh; p.active = p.active == null ? "" : p.active; p.remark = p.remark == null ? "" : p.remark; p.fsh = p.fsh == null ? "" : p.fsh; p.prolactin = p.prolactin == null ? "" : p.prolactin; p.rt_ovary_1 = p.rt_ovary_1 == null ? "" : p.rt_ovary_1; p.rt_ovary_2 = p.rt_ovary_2 == null ? "" : p.rt_ovary_2; p.endo = p.endo == null ? "" : p.endo; p.day1 = p.day1 == null ? "" : p.day1; p.e2 = p.e2 == null ? "" : p.e2; p.lt_ovary_1 = p.lt_ovary_1 == null ? "" : p.lt_ovary_1; p.lt_ovary_2 = p.lt_ovary_2 == null ? "" : p.lt_ovary_2; p.medication = p.medication == null ? "" : p.medication; p.medication2 = p.medication2 == null ? "" : p.medication2; }
private void initConfig() { eggsd = new EggStiDay(); eggsd.egg_sti_day_id = "egg_sti_day_id"; eggsd.egg_sti_id = "egg_sti_id"; eggsd.day1 = "day1"; eggsd.date = "date"; eggsd.e2 = "e2"; eggsd.lh = "lh"; eggsd.active = "active"; eggsd.remark = "remark"; eggsd.fsh = "fsh"; eggsd.date_create = "date_create"; eggsd.date_modi = "date_modi"; eggsd.date_cancel = "date_cancel"; eggsd.user_create = "user_create"; eggsd.user_modi = "user_modi"; eggsd.user_cancel = "user_cancel"; eggsd.prolactin = "prolactin"; eggsd.rt_ovary_1 = "rt_ovary_1"; eggsd.rt_ovary_2 = "rt_ovary_2"; eggsd.lt_ovary_1 = "lt_ovary_1"; eggsd.lt_ovary_2 = "lt_ovary_2"; eggsd.endo = "endo"; eggsd.medication = "medication"; eggsd.medication2 = "medication2"; eggsd.table = "nurse_t_egg_sti_day"; eggsd.pkField = "egg_sti_day_id"; lStf = new List <EggStiDay>(); }
private EggStiDay setEggSti(DataTable dt) { EggStiDay dept1 = new EggStiDay(); if (dt.Rows.Count > 0) { dept1.egg_sti_day_id = dt.Rows[0][eggsd.egg_sti_day_id].ToString(); dept1.egg_sti_id = dt.Rows[0][eggsd.egg_sti_id].ToString(); dept1.day1 = dt.Rows[0][eggsd.day1].ToString(); dept1.date = dt.Rows[0][eggsd.date].ToString(); dept1.e2 = dt.Rows[0][eggsd.e2].ToString(); dept1.lh = dt.Rows[0][eggsd.lh].ToString(); dept1.active = dt.Rows[0][eggsd.active].ToString(); dept1.remark = dt.Rows[0][eggsd.remark].ToString(); dept1.fsh = dt.Rows[0][eggsd.fsh].ToString(); dept1.date_create = dt.Rows[0][eggsd.date_create].ToString(); dept1.date_modi = dt.Rows[0][eggsd.date_modi].ToString(); dept1.date_cancel = dt.Rows[0][eggsd.date_cancel].ToString(); dept1.user_create = dt.Rows[0][eggsd.user_create].ToString(); dept1.user_modi = dt.Rows[0][eggsd.user_modi].ToString(); dept1.user_cancel = dt.Rows[0][eggsd.user_cancel].ToString(); dept1.prolactin = dt.Rows[0][eggsd.prolactin].ToString(); dept1.rt_ovary_1 = dt.Rows[0][eggsd.rt_ovary_1].ToString(); dept1.rt_ovary_2 = dt.Rows[0][eggsd.rt_ovary_2].ToString(); dept1.lt_ovary_1 = dt.Rows[0][eggsd.lt_ovary_1].ToString(); dept1.lt_ovary_2 = dt.Rows[0][eggsd.lt_ovary_2].ToString(); dept1.endo = dt.Rows[0][eggsd.endo].ToString(); dept1.medication = dt.Rows[0][eggsd.medication].ToString(); dept1.medication2 = dt.Rows[0][eggsd.medication2].ToString(); } else { dept1.egg_sti_day_id = ""; dept1.egg_sti_id = ""; dept1.day1 = ""; dept1.date = ""; dept1.e2 = ""; dept1.lh = ""; dept1.active = ""; dept1.remark = ""; dept1.fsh = ""; dept1.date_create = ""; dept1.date_modi = ""; dept1.date_cancel = ""; dept1.user_create = ""; dept1.user_modi = ""; dept1.user_cancel = ""; dept1.prolactin = ""; dept1.rt_ovary_1 = ""; dept1.rt_ovary_2 = ""; dept1.lt_ovary_1 = ""; dept1.lt_ovary_2 = ""; dept1.endo = ""; dept1.medication = ""; dept1.medication2 = ""; } return(dept1); }
private void BtnSave_Click(object sender, EventArgs e) { //throw new NotImplementedException(); if (txtId.Text.Equals("")) { MessageBox.Show("ID ไม่ถูกต้อง ", ""); return; } ic.cStf.staff_id = ""; FrmPasswordConfirm frm = new FrmPasswordConfirm(ic); frm.ShowDialog(this); if (!ic.cStf.staff_id.Equals("")) { setEggSti(); String re = ic.ivfDB.eggsDB.insertEggSti(eggs, ic.cStf.staff_id); for (int i = 1; i <= 17; i++) { if (grfEggsd.Rows[i][colEdit] == null) { continue; } if (grfEggsd.Rows[i][colEdit].ToString().Equals("1")) { EggStiDay eggsd = new EggStiDay(); eggsd.egg_sti_day_id = grfEggsd.Rows[i][colId].ToString(); eggsd.egg_sti_id = txtId.Text; eggsd.day1 = i.ToString(); eggsd.date = ""; eggsd.e2 = grfEggsd.Rows[i][colE2].ToString(); eggsd.lh = grfEggsd.Rows[i][colLH].ToString(); eggsd.active = ""; eggsd.remark = ""; eggsd.fsh = grfEggsd.Rows[i][colFSH].ToString(); eggsd.date_create = ""; eggsd.date_modi = ""; eggsd.date_cancel = ""; eggsd.user_create = ""; eggsd.user_modi = ""; eggsd.user_cancel = ""; eggsd.prolactin = grfEggsd.Rows[i][colProlactin].ToString(); eggsd.rt_ovary_1 = grfEggsd.Rows[i][colRt1].ToString(); eggsd.rt_ovary_2 = grfEggsd.Rows[i][colRt2].ToString(); eggsd.lt_ovary_1 = grfEggsd.Rows[i][colLt1].ToString(); eggsd.lt_ovary_2 = grfEggsd.Rows[i][colLt2].ToString(); eggsd.endo = grfEggsd.Rows[i][colEndo].ToString(); eggsd.medication = grfEggsd.Rows[i][colMedi].ToString(); ic.ivfDB.eggsdDB.insertEggStiDay(eggsd, ic.cStf.staff_id); } } } }
public EggStiDay selectByPk1(String pttId) { EggStiDay cop1 = new EggStiDay(); DataTable dt = new DataTable(); String sql = "select eggsd.* " + "From " + eggsd.table + " eggsd " + "Where eggsd." + eggsd.pkField + " ='" + pttId + "' "; dt = conn.selectData(conn.conn, sql); cop1 = setEggSti(dt); return(cop1); }
public String insertEggStiDay(EggStiDay p, String userId) { String re = ""; if (p.egg_sti_day_id.Equals("")) { re = insert(p, userId); } else { re = update1(p, userId); } return(re); }
public String insert(EggStiDay p, String userId) { String re = ""; String sql = ""; p.active = "1"; //p.ssdata_id = ""; int chk = 0; //eggsd.day1 = "day1"; //eggsd.table = "nurse_t_egg_sti_day"; chkNull(p); //opuEmDev.p = "p"; sql = "Insert Into " + eggsd.table + " Set " + " " + eggsd.day1 + "='" + p.day1 + "'" + "," + eggsd.date + "='" + p.date + "'" + "," + eggsd.e2 + "='" + p.e2 + "'" + "," + eggsd.lh + "='" + p.lh.Replace("'", "''") + "'" + "," + eggsd.active + "='" + p.active + "'" + "," + eggsd.remark + "='" + p.remark.Replace("'", "''") + "'" + "," + eggsd.fsh + "='" + p.fsh + "'" + "," + eggsd.date_create + "=now()" + "," + eggsd.user_create + "='" + userId + "@" + conn._IPAddress + "'" + "," + eggsd.prolactin + "='" + p.prolactin.Replace("'", "''") + "'" + "," + eggsd.rt_ovary_1 + "='" + p.rt_ovary_1.Replace("'", "''") + "'" + "," + eggsd.rt_ovary_2 + "='" + p.rt_ovary_2.Replace("'", "''") + "'" + "," + eggsd.lt_ovary_1 + "='" + p.lt_ovary_1.Replace("'", "''") + "'" + "," + eggsd.lt_ovary_2 + "='" + p.lt_ovary_2.Replace("'", "''") + "'" + "," + eggsd.endo + "='" + p.endo.Replace("'", "''") + "'" + "," + eggsd.egg_sti_id + "='" + p.egg_sti_id + "'" + "," + eggsd.medication + "='" + p.medication.Replace("'", "''") + "'" + "," + eggsd.medication2 + "='" + p.medication2.Replace("'", "''") + "'" + " " + ""; try { re = conn.ExecuteNonQuery(conn.conn, sql); } catch (Exception ex) { sql = ex.Message + " " + ex.InnerException; new LogWriter("e", "Err insert EggStiDay " + sql); } return(re); }
public String update(EggStiDay p, String userId) { String re = ""; String sql = ""; int chk = 0; chkNull(p); sql = "Update " + eggsd.table + " Set " + " " + eggsd.date + " = '" + p.date + "'" + "," + eggsd.e2 + " = '" + p.e2.Replace("'", "''") + "'" + "," + eggsd.lh + " = '" + p.lh.Replace("'", "''") + "'" + "," + eggsd.remark + " = '" + p.remark.Replace("'", "''") + "'" + "," + eggsd.prolactin + " = '" + p.prolactin.Replace("'", "''") + "'" + "," + eggsd.rt_ovary_1 + " = '" + p.rt_ovary_1.Replace("'", "''") + "'" + "," + eggsd.rt_ovary_2 + " = '" + p.rt_ovary_2.Replace("'", "''") + "'" + "," + eggsd.lt_ovary_1 + " = '" + p.lt_ovary_1.Replace("'", "''") + "'" + "," + eggsd.lt_ovary_2 + "='" + p.lt_ovary_2.Replace("'", "''") + "'" + "," + eggsd.endo + "='" + p.endo.Replace("'", "''") + "'" + "," + eggsd.fsh + "='" + p.fsh.Replace("'", "''") + "'" + //"," + eggsd.egg_sti_id + "='" + p.egg_sti_id + "'" + "," + eggsd.medication + "='" + p.medication.Replace("'", "''") + "'" + "," + eggsd.medication2 + "='" + p.medication2.Replace("'", "''") + "'" + "," + eggsd.date_modi + "=now()" + "," + eggsd.user_modi + "='" + userId + "@" + conn._IPAddress + "'" + "Where " + eggsd.pkField + "='" + p.egg_sti_day_id + "'" ; try { re = conn.ExecuteNonQuery(conn.conn, sql); } catch (Exception ex) { sql = ex.Message + " " + ex.InnerException; new LogWriter("e", "Err update EggStiDay " + sql); } return(re); }
private void BtnGenEggSti_Click(object sender, EventArgs e) { //throw new NotImplementedException(); String lmpdate = ""; DateTime lmpdate1 = new DateTime(); lmpdate = ic.datetoDB(txtVisitLMP.Text); if (!DateTime.TryParse(lmpdate, out lmpdate1)) { MessageBox.Show("วันที่ LMP Date ไม่ถูกต้อง ", ""); return; } if (MessageBox.Show("ต้องการ Day Egg Sti \nวันที่ LMP Date " + txtVisitLMP.Text, "", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button2) == DialogResult.OK) { setEggSti(); ic.cStf.staff_id = ""; FrmPasswordConfirm frm = new FrmPasswordConfirm(ic); frm.ShowDialog(this); if (!ic.cStf.staff_id.Equals("")) { int chk = 0; String re = ic.ivfDB.eggsDB.insertEggSti(eggs, ic.cStf.staff_id); if (int.TryParse(re, out chk)) { txtId.Value = re; lmpdate = ic.datetoDB(txtVisitLMP.Text); if (DateTime.TryParse(lmpdate, out lmpdate1)) { for (int i = 1; i <= 17; i++) { if (i != 1) { lmpdate1 = lmpdate1.AddDays(1); } EggStiDay eggsd = new EggStiDay(); eggsd.egg_sti_day_id = ""; eggsd.egg_sti_id = re; eggsd.day1 = i.ToString(); eggsd.date = ic.datetoDB(lmpdate1.Year.ToString() + "-" + lmpdate1.ToString("MM-dd")); eggsd.e2 = ""; eggsd.lh = ""; eggsd.active = ""; eggsd.remark = ""; eggsd.fsh = ""; eggsd.date_create = ""; eggsd.date_modi = ""; eggsd.date_cancel = ""; eggsd.user_create = ""; eggsd.user_modi = ""; eggsd.user_cancel = ""; eggsd.prolactin = ""; eggsd.rt_ovary_1 = ""; eggsd.rt_ovary_2 = ""; eggsd.lt_ovary_1 = ""; eggsd.lt_ovary_2 = ""; eggsd.endo = ""; eggsd.medication = ""; ic.ivfDB.eggsdDB.insertEggStiDay(eggsd, ic.cStf.staff_id); } } setControlEggSti(); } } } }