Пример #1
0
 public StockRecDetail setDocGroupScan(StockRecDetail dgs1)
 {
     dgs1.rec_detail_id = "";
     dgs1.rec_id        = "";
     dgs1.goods_id      = "";
     dgs1.price         = "";
     dgs1.cost          = "";
     dgs1.qty           = "";
     dgs1.amount        = "";
     dgs1.unit_id       = "";
     dgs1.active        = "";
     dgs1.remark        = "";
     dgs1.date_create   = "";
     dgs1.date_modi     = "";
     dgs1.date_cancel   = "";
     dgs1.user_create   = "";
     dgs1.user_modi     = "";
     dgs1.user_cancel   = "";
     dgs1.status_stock  = "";
     dgs1.row1          = "";
     dgs1.unit_name     = "";
     dgs1.date_expire   = "";
     dgs1.lot_no        = "";
     return(dgs1);
 }
Пример #2
0
        public void getlBsp()
        {
            //lDept = new List<Position>();

            lStkrD.Clear();
            DataTable dt = new DataTable();

            dt = selectAll();
            foreach (DataRow row in dt.Rows)
            {
                StockRecDetail itm1 = new StockRecDetail();
                itm1.rec_detail_id = row[stkrd.rec_detail_id].ToString();
                itm1.rec_id        = row[stkrd.rec_id].ToString();
                itm1.goods_id      = row[stkrd.goods_id].ToString();
                itm1.price         = row[stkrd.price].ToString();
                itm1.cost          = row[stkrd.cost].ToString();
                itm1.qty           = row[stkrd.qty].ToString();
                itm1.amount        = row[stkrd.amount].ToString();
                itm1.unit_id       = row[stkrd.unit_id].ToString();
                itm1.active        = row[stkrd.active].ToString();
                itm1.remark        = row[stkrd.remark].ToString();
                itm1.date_create   = row[stkrd.date_create].ToString();
                itm1.date_modi     = row[stkrd.date_modi].ToString();
                itm1.date_cancel   = row[stkrd.date_cancel].ToString();
                itm1.user_create   = row[stkrd.user_create].ToString();
                itm1.user_modi     = row[stkrd.user_modi].ToString();
                itm1.user_cancel   = row[stkrd.user_cancel].ToString();
                itm1.status_stock  = row[stkrd.status_stock].ToString();

                lStkrD.Add(itm1);
            }
        }
Пример #3
0
        private void initConfig()
        {
            stkrd  = new StockRecDetail();
            lStkrD = new List <StockRecDetail>();

            stkrd.rec_detail_id = "rec_detail_id";
            stkrd.rec_id        = "rec_id";
            stkrd.goods_id      = "goods_id";
            stkrd.price         = "price";
            stkrd.cost          = "cost";
            stkrd.qty           = "qty";
            stkrd.amount        = "amount";
            stkrd.unit_id       = "unit_id";
            stkrd.active        = "active";
            stkrd.remark        = "remark";
            stkrd.date_create   = "date_create";
            stkrd.date_modi     = "date_modi";
            stkrd.date_cancel   = "date_cancel";
            stkrd.user_create   = "user_create";
            stkrd.user_modi     = "user_modi";
            stkrd.user_cancel   = "user_cancel";
            stkrd.status_stock  = "status_stock";
            stkrd.row1          = "row1";
            stkrd.unit_name     = "unit_name";
            stkrd.date_expire   = "date_expire";
            stkrd.lot_no        = "lot_no";

            stkrd.table   = "t_stock_rec_detail";
            stkrd.pkField = "rec_detail_id";
        }
Пример #4
0
        public StockRecDetail setDocScan(DataTable dt)
        {
            StockRecDetail dgs1 = new StockRecDetail();

            if (dt.Rows.Count > 0)
            {
                dgs1.rec_detail_id = dt.Rows[0][stkrd.rec_detail_id].ToString();
                dgs1.rec_id        = dt.Rows[0][stkrd.rec_id].ToString();
                dgs1.goods_id      = dt.Rows[0][stkrd.goods_id].ToString();
                dgs1.price         = dt.Rows[0][stkrd.price].ToString();
                dgs1.cost          = dt.Rows[0][stkrd.cost].ToString();
                dgs1.qty           = dt.Rows[0][stkrd.qty].ToString();
                dgs1.amount        = dt.Rows[0][stkrd.amount].ToString();
                dgs1.unit_id       = dt.Rows[0][stkrd.unit_id].ToString();
                dgs1.active        = dt.Rows[0][stkrd.active].ToString();
                dgs1.remark        = dt.Rows[0][stkrd.remark].ToString();
                dgs1.date_create   = dt.Rows[0][stkrd.date_create].ToString();
                dgs1.date_modi     = dt.Rows[0][stkrd.date_modi].ToString();
                dgs1.date_cancel   = dt.Rows[0][stkrd.date_cancel].ToString();
                dgs1.user_create   = dt.Rows[0][stkrd.user_create].ToString();
                dgs1.user_modi     = dt.Rows[0][stkrd.user_modi].ToString();
                dgs1.user_cancel   = dt.Rows[0][stkrd.user_cancel].ToString();
                dgs1.status_stock  = dt.Rows[0][stkrd.status_stock].ToString();
                dgs1.row1          = dt.Rows[0][stkrd.row1].ToString();
                dgs1.unit_name     = dt.Rows[0][stkrd.unit_name].ToString();
                dgs1.date_expire   = dt.Rows[0][stkrd.date_expire].ToString();
                dgs1.lot_no        = dt.Rows[0][stkrd.lot_no].ToString();
            }
            else
            {
                setDocGroupScan(dgs1);
            }
            return(dgs1);
        }
Пример #5
0
        private void chkNull(StockRecDetail 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.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.unit_id      = p.unit_id == null ? "" : p.unit_id;
            p.remark       = p.remark == null ? "" : p.remark;
            p.status_stock = p.status_stock == null ? "" : p.status_stock;
            p.unit_name    = p.unit_name == null ? "" : p.unit_name;
            p.date_expire  = p.date_expire == null ? "" : p.date_expire;
            p.lot_no       = p.lot_no == null ? "" : p.lot_no;

            p.rec_id   = long.TryParse(p.rec_id, out chk) ? chk.ToString() : "0";
            p.goods_id = long.TryParse(p.goods_id, out chk) ? chk.ToString() : "0";
            p.unit_id  = long.TryParse(p.unit_id, out chk) ? chk.ToString() : "0";
            p.row1     = long.TryParse(p.row1, out chk) ? chk.ToString() : "0";

            p.price  = Decimal.TryParse(p.price, out chk1) ? chk1.ToString() : "0";
            p.cost   = Decimal.TryParse(p.cost, out chk1) ? chk1.ToString() : "0";
            p.qty    = Decimal.TryParse(p.qty, out chk1) ? chk1.ToString() : "0";
            p.amount = Decimal.TryParse(p.amount, out chk1) ? chk1.ToString() : "0";
        }
Пример #6
0
        public DataTable selectByRecId(String recid)
        {
            StockRecDetail cop1 = new StockRecDetail();
            DataTable      dt   = new DataTable();
            String         sql  = "select * " +
                                  "From " + stkrd.table + " dsc " +
                                  //"Left Join f_patient_prefix pfx On stf.prefix_id = pfx.f_patient_prefix_id " +
                                  "Where dsc." + stkrd.rec_id + " ='" + recid + "' and dsc." + stkrd.active + "='1'" +
                                  "Order By rec_id ";

            dt = conn.selectData(conn.conn, sql);

            return(dt);
        }
Пример #7
0
        public StockRecDetail selectByPk(String id)
        {
            StockRecDetail cop1 = new StockRecDetail();
            DataTable      dt   = new DataTable();
            String         sql  = "select * " +
                                  "From " + stkrd.table + " dsc " +
                                  //"Left Join f_patient_prefix pfx On stf.prefix_id = pfx.f_patient_prefix_id " +
                                  "Where dsc." + stkrd.pkField + " ='" + id + "' " +
                                  "Order By rec_id ";

            dt   = conn.selectData(conn.conn, sql);
            cop1 = setDocScan(dt);
            return(cop1);
        }
Пример #8
0
        public String insertDocScan(StockRecDetail p, String userId)
        {
            String re = "";

            if (p.rec_detail_id.Equals(""))
            {
                re = insert(p, "");
            }
            else
            {
                re = update(p, "");
            }

            return(re);
        }
Пример #9
0
        public String insert(StockRecDetail 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 " + stkrd.table + " set " +
                  "" + stkrd.rec_id + "= '" + p.rec_id + "'" +
                  "," + stkrd.active + "= '" + p.active + "'" +
                  "," + stkrd.goods_id + "= '" + p.goods_id + "'" +
                  "," + stkrd.price + "= '" + p.price + "'" +
                  "," + stkrd.cost + "= '" + p.cost + "'" +
                  "," + stkrd.qty + "= '" + p.qty + "'" +
                  "," + stkrd.amount + "= '" + p.amount + "'" +
                  "," + stkrd.unit_id + "= '" + p.unit_id + "'" +
                  "," + stkrd.remark + "= '" + p.remark + "'" +
                  "," + stkrd.date_create + "= now()" +
                  "," + stkrd.date_modi + "= ''" +
                  "," + stkrd.date_cancel + "= ''" +
                  "," + stkrd.user_create + "= '" + userId + "'" +
                  "," + stkrd.user_modi + "= ''" +
                  "," + stkrd.user_cancel + "= ''" +
                  "," + stkrd.status_stock + "= '" + p.status_stock + "'" +
                  "," + stkrd.row1 + "= '" + p.row1 + "'" +
                  "," + stkrd.unit_name + "= '" + p.unit_name + "'" +
                  "," + stkrd.date_expire + "= '" + p.date_expire + "'" +
                  "," + stkrd.lot_no + "= '" + p.lot_no + "'" +
                  "";
            try
            {
                re = conn.ExecuteNonQuery(conn.conn, sql);
            }
            catch (Exception ex)
            {
                sql = ex.Message + " " + ex.InnerException;
            }
            finally
            {
                conn.conn.Close();
                //conn.comStore.Dispose();
            }
            return(re);
        }
Пример #10
0
        public String update(StockRecDetail p, String userId)
        {
            String re  = "";
            String sql = "";
            int    chk = 0;

            chkNull(p);
            sql = "Update " + stkrd.table + " Set " +
                  " " + stkrd.rec_id + " = '" + p.rec_id + "'" +
                  "," + stkrd.goods_id + " = '" + p.goods_id + "'" +
                  "," + stkrd.price + " = '" + p.price + "'" +
                  "," + stkrd.cost + " = '" + p.cost + "'" +
                  "," + stkrd.qty + " = '" + p.qty + "'" +
                  "," + stkrd.amount + " = '" + p.amount + "'" +
                  "," + stkrd.unit_id + " = '" + p.unit_id + "'" +
                  "," + stkrd.remark + " = '" + p.remark + "'" +
                  "," + stkrd.date_modi + " = now()" +
                  "," + stkrd.user_modi + " = '" + userId + "'" +
                  "," + stkrd.status_stock + " = '" + p.status_stock + "'" +
                  "," + stkrd.row1 + " = '" + p.row1 + "'" +
                  "," + stkrd.unit_name + " = '" + p.unit_name + "'" +
                  "," + stkrd.date_expire + " = '" + p.date_expire + "'" +
                  "," + stkrd.lot_no + " = '" + p.lot_no + "'" +
                  "Where " + stkrd.pkField + "='" + p.rec_detail_id + "'"
            ;

            try
            {
                re = conn.ExecuteNonQuery(conn.conn, sql);
            }
            catch (Exception ex)
            {
                sql = ex.Message + " " + ex.InnerException;
            }

            return(re);
        }
Пример #11
0
        private void BtnSave_Click(object sender, EventArgs e)
        {
            //throw new NotImplementedException();
            if (MessageBox.Show("ต้องการ บันทึกช้อมูล ", "", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button2) == DialogResult.OK)
            {
                setStockDrug();
                String re = ic.ivfDB.stkrDB.insertStockRec(stkr, ic.user.staff_id);
                //txtId.Value = re;
                long chk = 0;
                if (long.TryParse(re, out chk))
                {
                    if (chk > 1)
                    {
                        txtId.Value = re;
                    }
                    foreach (Row row in grfStk.Rows)
                    {
                        if (row[colCode] == null)
                        {
                            continue;
                        }
                        if (row[colCode].Equals(""))
                        {
                            continue;
                        }
                        if (row[colQty] == null)
                        {
                            continue;
                        }
                        if (row[colQty].Equals(""))
                        {
                            continue;
                        }
                        if (row[colEdit] == null)
                        {
                            continue;
                        }
                        if (!row[colEdit].Equals("1"))
                        {
                            continue;
                        }

                        StockRecDetail stkrd = new StockRecDetail();
                        stkrd.rec_detail_id = row[colId] != null ? row[colId].ToString() : "";
                        stkrd.rec_id        = txtId.Text;
                        stkrd.goods_id      = row[colCode] != null ? row[colCode].ToString() : "";
                        stkrd.price         = row[colPrice] != null ? row[colPrice].ToString() : "";
                        stkrd.cost          = "";
                        stkrd.qty           = row[colQty] != null ? row[colQty].ToString() : "";
                        stkrd.amount        = "";
                        stkrd.unit_id       = "";
                        stkrd.active        = "";
                        stkrd.remark        = row[colRemark] != null ? row[colRemark].ToString() : "";
                        stkrd.date_create   = "";
                        stkrd.date_modi     = "";
                        stkrd.date_cancel   = "";
                        stkrd.user_create   = "";
                        stkrd.user_modi     = "";
                        stkrd.user_cancel   = "";
                        stkrd.status_stock  = "1";
                        stkrd.row1          = row[0] != null ? row[0].ToString() : "";
                        stkrd.unit_name     = row[colUnit] != null ? row[colUnit].ToString() : "";
                        stkrd.date_expire   = row[colExpDate] != null?ic.datetoDB(row[colExpDate].ToString()) : "";

                        stkrd.lot_no = row[colLotNo] != null ? row[colLotNo].ToString() : "";
                        String re1 = ic.ivfDB.stkrdDB.insertDocScan(stkrd, ic.user.staff_id);
                        row[colId] = re1;
                    }
                    btnSave.Image = Resources.accept_database24;
                }
                else
                {
                    btnSave.Image = Resources.accept_database24;
                }
                //setGrfStockDrug();
            }
        }