Example #1
0
        public bool NewStockOut(string userID, double requisition, double warehouse)
        {
            bool ret = true;
            OracleDBObj obj = new OracleDBObj();
            obj.CreateConnection();
            obj.CreateTransaction();
            try
            {
                RequisitionDAL reqDAL = new RequisitionDAL();
                reqDAL.GetDataByLOID(requisition, obj.zTrans);

                ReqMaterialDAL reqItemDAL = new ReqMaterialDAL();
                DataTable dt = CompareLot(reqItemDAL.GetDataByRequisition(requisition, obj.zTrans),warehouse);

                DocTypeDAL docDAL = new DocTypeDAL();
                docDAL.GetDataByRequisitionType(reqDAL.REQUISITIONTYPE, obj.zTrans);

                StockOutDAL _DAL = new StockOutDAL();
                _DAL.OnDB = false;
                _DAL.ACTIVE = Constz.ActiveStatus.Active;
                _DAL.DOCTYPE = docDAL.LOID;
                _DAL.RECEIVER = (reqDAL.CUSTOMER != 0 ? reqDAL.CUSTOMER : reqDAL.WAREHOUSE);
                _DAL.REFLOID = reqDAL.LOID;
                _DAL.REFTABLE = reqDAL.TableName;
                _DAL.REQDATE = reqDAL.REQDATE;
                _DAL.SENDER = warehouse;
                _DAL.STATUS = Constz.Requisition.Status.Waiting.Code;
                _DAL.PRODUCTREF = "PDPRODUCT";
                _DAL.PRODUCTLOID = reqDAL.REFLOID;

                ret = _DAL.InsertCurrentData(userID, obj.zTrans);
                if (!ret)
                {
                    throw new ApplicationException(_DAL.ErrorMessage);
                }
                StockOutItemDAL _DALItem = new StockOutItemDAL();
                foreach (DataRow dRow in dt.Rows)
                {
                    _DALItem.OnDB = false;
                    _DALItem.LOTNO = dRow["LOTNO"].ToString();
                    _DALItem.PRODUCT = Convert.ToDouble(dRow["PRODUCT"]);
                    _DALItem.QTY = Convert.ToDouble(dRow["MASTER"]);
                    _DALItem.REFLOID = Convert.ToDouble(dRow["LOID"]);
                    _DALItem.REFTABLE = "REQUISITIONITEM";
                    _DALItem.STATUS = Constz.Requisition.Status.Waiting.Code;
                    _DALItem.STOCKOUT = _DAL.LOID;
                    _DALItem.UNIT = Convert.ToDouble(dRow["UNIT"]);
                    _DALItem.ACTIVE = Constz.ActiveStatus.Active;
                    _DALItem.REMAIN = Convert.ToDouble(dRow["REMAINQTY"]);

                    ret = _DALItem.InsertCurrentData(userID, obj.zTrans);
                    if (!ret)
                    {
                        throw new ApplicationException(_DALItem.ErrorMessage);
                    }
                }

                _LOID = _DAL.LOID;

                obj.zTrans.Commit();
                obj.CloseConnection();
            }
            catch (Exception ex)
            {
                obj.zTrans.Rollback();
                obj.CloseConnection();
                ret = false;
                _error = ex.Message;
            }
            return ret;
        }
Example #2
0
        public bool NewStockOut(string userID, double requisition, double warehouse)
        {
            bool ret = true;
            OracleDBObj obj = new OracleDBObj();
            obj.CreateConnection();
            obj.CreateTransaction();
            try
            {
                RequisitionDAL reqDAL = new RequisitionDAL();
                reqDAL.GetDataByLOID(requisition, obj.zTrans);

                RequisitionItemDAL reqItemDAL = new RequisitionItemDAL();
                DataTable dt = reqItemDAL.GetDataByRequisition(requisition, obj.zTrans);

                DocTypeDAL docDAL = new DocTypeDAL();
                docDAL.GetDataByRequisitionType(reqDAL.REQUISITIONTYPE, obj.zTrans);

                StockOutDAL _DAL = new StockOutDAL();
                _DAL.OnDB = false;
                _DAL.ACTIVE = Constz.ActiveStatus.Active;
                _DAL.DOCTYPE = docDAL.LOID;
                _DAL.RECEIVER = (reqDAL.CUSTOMER != 0 ? reqDAL.CUSTOMER : reqDAL.WAREHOUSE);
                _DAL.REFLOID = reqDAL.LOID;
                _DAL.REFTABLE = reqDAL.TableName;
                _DAL.REQDATE = reqDAL.REQDATE;
                _DAL.SENDER = warehouse;
                _DAL.STATUS = Constz.Requisition.Status.Waiting.Code;
                _DAL.CTITLE = reqDAL.CTITLE;
                _DAL.CNAME = reqDAL.CNAME;
                _DAL.CLASTNAME = reqDAL.CLASTNAME;
                _DAL.CADDRESS = reqDAL.CADDRESS;
                _DAL.CFAX = reqDAL.CFAX;
                _DAL.CTEL = reqDAL.CTEL;

                ret = _DAL.InsertCurrentData(userID, obj.zTrans);
                if (!ret)
                {
                    throw new ApplicationException(_DAL.ErrorMessage);
                }
                StockOutItemDAL _DALItem = new StockOutItemDAL();
                foreach (DataRow dRow in dt.Rows)
                {
                    StockFGDAL fgDAL = new StockFGDAL();
                    double qty = Convert.ToDouble(dRow["QTY"]);
                    DataTable dtStock = fgDAL.GetProductStock(warehouse, Convert.ToDouble(dRow["PRODUCT"]), obj.zTrans);
                    foreach (DataRow sRow in dtStock.Rows)
                    {
                        _DALItem.OnDB = false;
                        _DALItem.LOTNO = sRow["LOTNO"].ToString();
                        _DALItem.PRODUCT = Convert.ToDouble(dRow["PRODUCT"]);
                        if (qty >= Convert.ToDouble(sRow["QTY"]))
                            _DALItem.QTY = Convert.ToDouble(sRow["QTY"]);
                        else
                            _DALItem.QTY = qty;
                        _DALItem.REFLOID = Convert.ToDouble(dRow["LOID"]);
                        _DALItem.REFTABLE = "REQUISITIONITEM";
                        _DALItem.STATUS = Constz.Requisition.Status.Waiting.Code;
                        _DALItem.STOCKOUT = _DAL.LOID;
                        _DALItem.UNIT = Convert.ToDouble(dRow["UNIT"]);
                        _DALItem.ACTIVE = Constz.ActiveStatus.Active;
                        _DALItem.PRICE = Convert.ToDouble(dRow["PRICE"]);
                        double remain = _DALItem.GetRemainQTYStockFG(_DALItem.LOTNO, _DALItem.PRODUCT, obj.zTrans);
                        _DALItem.REMAIN = remain;
                        qty -= Convert.ToDouble(sRow["QTY"]);

                        ret = _DALItem.InsertCurrentData(userID, obj.zTrans);
                        if (!ret)
                        {
                            throw new ApplicationException(_DALItem.ErrorMessage);
                        }

                        if (qty <= 0) break;
                    }

                }

                _LOID = _DAL.LOID;

                obj.zTrans.Commit();
                obj.CloseConnection();
            }
            catch (Exception ex)
            {
                obj.zTrans.Rollback();
                obj.CloseConnection();
                ret = false;
                _error = ex.Message;
            }
            return ret;
        }
Example #3
0
 public StockInShopData GetStockOutData(double stockOut)
 {
     StockInShopData data = new StockInShopData();
     StockOutDAL sDAL = new StockOutDAL();
     sDAL.TableName = "STOCKOUT" + Constz.ABBSERV + "";
     sDAL.GetDataByLOID(stockOut, null);
     data.CODE = sDAL.CODE;
     data.RECEIVER = sDAL.RECEIVER;
     data.REFLOID = sDAL.LOID;
     data.SENDER = sDAL.RECEIVER;
     RequisitionDAL rDAL = new RequisitionDAL();
     rDAL.TableName = "REQUISITION" + Constz.ABBSERV + "";
     rDAL.GetDataByLOID(sDAL.REFLOID, null);
     data.REQUISITIONCODE = rDAL.CODE;
     DataTable dt = SearchObj.GetStockOutProductList(stockOut);
     int i = 1;
     foreach (DataRow dRow in dt.Rows)
     {
         dRow["ORDERNO"] = i;
         i += 1;
     }
     data.ITEM = dt;
     return data;
 }
Example #4
0
 public StockInShopData GetStockOutData(string requisitionCode, double currentStockIn)
 {
     double stockOut = 0;
     ABB.Data.Search.StockOutProductSearchData searchData = new ABB.Data.Search.StockOutProductSearchData();
     searchData.REQUISITIONCODEFROM = requisitionCode;
     searchData.REQUISITIONCODETO = requisitionCode;
     DataTable dtSearch = GetStockOutList(searchData, currentStockIn);
     if (dtSearch.Rows.Count == 1)
     {
         stockOut = Convert.ToDouble(dtSearch.Rows[0]["STOCKOUT"]);
     }
     StockInShopData data = new StockInShopData();
     StockOutDAL sDAL = new StockOutDAL();
     sDAL.TableName = "STOCKOUT" + Constz.ABBSERV + "";
     sDAL.GetDataByLOID(stockOut, null);
     data.CODE = sDAL.CODE;
     data.RECEIVER = sDAL.RECEIVER;
     data.REFLOID = sDAL.LOID;
     data.SENDER = sDAL.RECEIVER;
     RequisitionDAL rDAL = new RequisitionDAL();
     rDAL.TableName = "REQUISITION" + Constz.ABBSERV + "";
     rDAL.GetDataByLOID(sDAL.REFLOID, null);
     data.REQUISITIONCODE = rDAL.CODE;
     DataTable dt = SearchObj.GetStockOutProductList(stockOut);
     int i = 1;
     foreach (DataRow dRow in dt.Rows)
     {
         dRow["ORDERNO"] = i;
         i += 1;
     }
     data.ITEM = dt;
     return data;
 }
Example #5
0
        public bool CancelData(double requisition, string userID)
        {
            bool ret = true;
            OracleDBObj obj = new OracleDBObj();
            obj.CreateConnection();
            obj.CreateTransaction();
            try
            {
                DALObj.OnDB = false;
                DALObj.GetDataByLOID(requisition, obj.zTrans);
                StockOutDAL sDAL = new StockOutDAL();

                if (DALObj.STATUS == Constz.Requisition.Status.Approved.Code)
                {
                    if (sDAL.TotalReference("REQUISITION", requisition, obj.zTrans) > 0)
                        throw new ApplicationException("äÁèÊÒÁÒö¡àÅÔ¡ÃÒ¡ÒÃä´é à¹×èͧ¨Ò¡ÃÒ¡ÒùÕé¶Ù¡ÍéÒ§Íԧ㹡Ò÷ÓÃÒ¡ÒõèÍáÅéÇ");
                    else
                    {
                        DALObj.STATUS = Constz.Requisition.Status.Void.Code;

                        ret = DALObj.UpdateCurrentData(userID, obj.zTrans);
                        if (!ret) throw new ApplicationException(DALObj.ErrorMessage);
                        ret = DALObj.CutStockRequisition(requisition, userID, obj.zTrans);
                        if (!ret) throw new ApplicationException(DALObj.ErrorMessage);
                    }
                }

                obj.zTrans.Commit();
                obj.CloseConnection();
            }
            catch (Exception ex)
            {
                obj.zTrans.Rollback();
                obj.CloseConnection();
                ret = false;
                _error = ex.Message;
            }
            return ret;
        }