Exemplo n.º 1
0
 public bool SetInvoiceCode(string userID, double requisition)
 {
     bool ret = true;
     OracleDBObj obj = new OracleDBObj();
     obj.CreateConnection();
     obj.CreateTransaction();
     try
     {
         RequisitionDAL reqDAL = new RequisitionDAL();
         reqDAL.GetDataByLOID(requisition, obj.zTrans);
         if (reqDAL.INVCODE == "")
         {
             reqDAL.INVCODE = OracleDB.GetRunningCode("REQUISITION_INVCODE", reqDAL.REQUISITIONTYPE.ToString(), obj.zTrans);
             ret = reqDAL.UpdateCurrentData(userID, obj.zTrans);
             if (!ret) throw new ApplicationException(reqDAL.ErrorMessage);
         }
         obj.zTrans.Commit();
         obj.CloseConnection();
     }
     catch (Exception ex)
     {
         obj.zTrans.Rollback();
         obj.CloseConnection();
         ret = false;
         _error = ex.Message;
     }
     return ret;
 }
Exemplo n.º 2
0
        public bool SubmitReturnRequisition(ArrayList arrData, string userID)
        {
            bool ret = true;
            OracleDBObj obj = new OracleDBObj();
            obj.CreateConnection();
            obj.CreateTransaction();
            try
            {
                for (int i = 0; i < arrData.Count; ++i)
                {
                    DALObj.OnDB = false;
                    DALObj.GetDataByLOID(Convert.ToDouble(arrData[i]), obj.zTrans);
                    if (DALObj.STATUS == Constz.Requisition.Status.Waiting.Code)
                    {
                        DALObj.STATUS = Constz.Requisition.Status.Approved.Code;
                        ret = DALObj.UpdateCurrentData(userID, obj.zTrans);
                        if (!ret) throw new ApplicationException(DALObj.ErrorMessage);

                        ret = DALObj.CutStockRequisition(Convert.ToDouble(arrData[i]), 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;
        }
Exemplo n.º 3
0
        public bool DeleteBomData(ArrayList arr)
        {
            bool ret = true;
            OracleDBObj obj = new OracleDBObj();
            obj.CreateTransaction();
            try
            {
                for (int i = 0; i < arr.Count; ++i)
                {
                    double product = Convert.ToDouble(arr[i]);
                    if (BarcodeDAL.GetDataByLOID(product, obj.zTrans))
                    {
                        ret = BomItem.DeleteDataByMainProduct(product, obj.zTrans);
                        if (!ret) throw new ApplicationException(BomItem.ErrorMessage);

                        if (ProcessItem.GetDataList("WHERE PRODUCT = " + BarcodeDAL.PRODUCTMASTER.ToString(), obj.zTrans).Rows.Count == 1)
                        {
                            ret = ProcessItem.DeleteDataByProduct(BarcodeDAL.PRODUCTMASTER, obj.zTrans);
                            if (!ret) throw new ApplicationException(ProcessItem.ErrorMessage);
                        }
                    }
                }
                obj.zTrans.Commit();
                obj.CloseConnection();
            }
            catch (Exception ex)
            {
                ret = false;
                obj.zTrans.Rollback();
                obj.CloseConnection();
            }
            return ret;
        }
Exemplo n.º 4
0
        public bool UpdateData(string userID, CreditCardData data)
        {
            bool ret = true;
            if (ValidateData(data))
            {
                OracleDBObj obj = new OracleDBObj();
                obj.CreateConnection();
                obj.CreateTransaction();
                try
                {
                    DALObj.GetDataByLOID(data.LOID, obj.zTrans);
                    DALObj.NAME = data.NAME.Trim();
                    DALObj.CHARGE = data.CHARGE;
                    DALObj.ACTIVE = data.ACTIVE.Trim();

                    if (DALObj.OnDB)
                        ret = DALObj.UpdateCurrentData(userID, obj.zTrans);
                    else
                        ret = DALObj.InsertCurrentData(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;
                }
            }
            else
                ret = false;
            return ret;
        }
Exemplo n.º 5
0
        public bool UpdateData(string userID, DepartmentData data)
        {
            bool ret = true;
            if (VeridateData(data))
            {

                OracleDBObj obj = new OracleDBObj();
                obj.CreateConnection();
                obj.CreateTransaction();
                try
                {
                    SearchDAL.GetDataByLOID(data.LOID, obj.zTrans);
                    SearchDAL.LOID = data.LOID;
                    SearchDAL.TNAME = data.TNAME.Trim();
                    SearchDAL.CODE = data.CODE.Trim();
                    SearchDAL.EFDATE = data.EFDATE;
                    SearchDAL.EPDATE = data.EPDATE;

                    if (SearchDAL.OnDB)
                        ret = SearchDAL.UpdateCurrentData(userID, obj.zTrans);
                    else
                        ret = SearchDAL.InsertCurrentData(userID, obj.zTrans);
                   
                    _LOID = SearchDAL.LOID;

                    if (ret)
                    {
                        obj.zTrans.Commit();
                        obj.CloseConnection();
                    }
                    else
                    {
                        _error = SearchDAL.ErrorMessage;
                    }
                }
                catch (Exception ex)
                {
                    obj.zTrans.Rollback();
                    obj.CloseConnection();
                    ret = false;
                    throw new ApplicationException(ex.Message);
                }
            }
            else
                ret = false;
            return ret;
        }
Exemplo n.º 6
0
        public bool CommitData(ArrayList arrData, double Approver, string userID)
        {
            bool ret = true;
            OracleDBObj obj = new OracleDBObj();
            obj.CreateTransaction();
            try
            {
                for (int i = 0; i < arrData.Count; ++i)
                {
                    double loid = Convert.ToDouble(arrData[i]);
                    DALObj.OnDB = false;
                    DALObj.GetDataByLOID(loid, obj.zTrans);
                    if (DALObj.STATUS == Constz.Requisition.Status.Waiting.Code)
                    {
                        if (DALItemObj.GetDataList("WHERE STOCKIN = " + loid.ToString(), obj.zTrans).Rows.Count <= 0) throw new ApplicationException("ÃÒ¡ÒÃàÅ¢·Õè " + DALObj.CODE + " äÁèä´éÃкØÃÒ¡ÒÃÊÔ¹¤éÒ");
                        DALObj.APPROVEDATE = DateTime.Today;
                        DALObj.APPROVER = Approver;
                        DALObj.STATUS = Constz.Requisition.Status.Approved.Code;
                        ret = DALObj.UpdateCurrentData(userID, obj.zTrans);
                        if (!ret) throw new ApplicationException(DALObj.ErrorMessage);
                        ret = DALItemObj.UpdateStatusByStockIn(loid, DALObj.STATUS, userID, obj.zTrans);
                        if (!ret) throw new ApplicationException(DALItemObj.ErrorMessage);

                        //ret = DALObj.CutStock(loid, userID, obj.zTrans);
                        ret = DALObj.CutStock(loid, userID, obj.zTrans);
                        if (!ret) throw new ApplicationException(DALObj.ErrorMessage);
                    }
                }
                if (obj.zTrans != null) obj.zTrans.Commit();
                obj.CloseConnection();
            }
            catch (Exception ex)
            {
                ret = false;
                _error = ex.Message;
                if (obj.zTrans != null) obj.zTrans.Rollback();
                obj.CloseConnection();
            }
            return ret;
        }
Exemplo n.º 7
0
        public bool UpdateStockCheckStatus(string batchno, string status, string userID ,ArrayList arr)
        {
            OracleDBObj obj = new OracleDBObj();
            obj.CreateConnection();
            obj.CreateTransaction();
            bool ret = true;

            try
            {
                string sql = "UPDATE STOCKCHECK SET STATUS = '" + status + "', ";
                sql += "UPDATEBY = '" + userID + "', ";
                sql += "UPDATEON = " + OracleDB.QRDateTime() + " ";
                sql += "WHERE BATCHNO='" + batchno + "'";

                ret = (OracleDB.ExecNonQueryCmd(sql, obj.zTrans) > 0);
                if (!ret)
                {
                    throw new ApplicationException(OracleDB.Err_NoExistUpdate);
                }

                StockCheckImproveDAL itemDAL = new StockCheckImproveDAL();

                for (Int16 i = 0; i < arr.Count; i++)
                {
                    itemDAL.OnDB = false;
                    StockCheckImproveData item = (StockCheckImproveData)arr[i];
                    double ans = item.SYSQTY + item.IMPROVEQTY;
                    itemDAL.STOCKCHECK = item.STOCKCHECK;
                    itemDAL.PRODUCTSTOCK = item.PRODUCTSTOCK;
                    itemDAL.SYSQTY = item.SYSQTY;
                    itemDAL.IMPROVEQTY = ans;
                    itemDAL.REASON = item.REASON;

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

                    sql = "UPDATE PRODUCTSTOCK SET QTY = '" + ans.ToString() + "', ";
                    sql += "UPDATEBY = '" + userID + "', ";
                    sql += "UPDATEON = " + OracleDB.QRDateTime() + " ";
                    sql += "WHERE LOID='" + item.PRODUCTSTOCK.ToString() + "'";

                    ret = (OracleDB.ExecNonQueryCmd(sql, obj.zTrans) > 0);
                    if (!ret)
                    {
                        throw new ApplicationException(OracleDB.Err_NoExistUpdate);
                    }
                }
                obj.zTrans.Commit();
                obj.CloseConnection();
            }
            catch (Exception ex)
            {
                obj.zTrans.Rollback();
                obj.CloseConnection();
                ret = false;
                _error = ex.Message;
            }

            return ret;
        }
Exemplo n.º 8
0
        public bool UpdateQty(double loid, double poloid, double pdloid, double qty, string userID)
        {
            bool ret = true;
            OracleDBObj obj = new OracleDBObj();
            obj.CreateConnection();
            obj.CreateTransaction();
            try
            {
                UpdateQty(loid, poloid, pdloid, qty, userID, obj.zTrans);

                obj.zTrans.Commit();
                obj.CloseConnection();
            }
            catch (Exception ex)
            {
                obj.zTrans.Rollback();
                obj.CloseConnection();
                ret = false;
                _error = ex.Message;
            }
            return ret;
        }
Exemplo n.º 9
0
 public bool DeleteData(ArrayList arrData)
 {
     bool ret = true;
     OracleDBObj obj = new OracleDBObj();
     obj.CreateConnection();
     obj.CreateTransaction();
     try
     {
         StockInItemDAL itemDAL = new StockInItemDAL();
         for (int i = 0; i < arrData.Count; i++)
         {
             DALObj.GetDataByLOID(Convert.ToDouble(arrData[i]), obj.zTrans);
             itemDAL.DeleteDataByStockIn(Convert.ToDouble(arrData[i]), obj.zTrans);
             ret = DALObj.DeleteCurrentData(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;
 }
Exemplo n.º 10
0
        public bool CommitQCData(string userID, StockInFGData data)
        {
            bool ret = true;
            if (ValidateData(data))
            {
                OracleDBObj obj = new OracleDBObj();
                obj.CreateConnection();
                obj.CreateTransaction();
                try
                {
                    data.QCCODE = OracleDB.GetRunningCode("STOCKIN_QC", data.DOCTYPE.ToString());
                    data.QCDATE = DateTime.Now.Date;
                    UpdateData(userID, data, obj.zTrans);

                    ret = DALObj.CutStock(_LOID, 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;
                }
            }
            else
                ret = false;
            return ret;
        }
Exemplo n.º 11
0
        public bool insertStockCheckItem(string userID, StockCheckItemData data)
        {
            bool ret = true;
            if (VerifyData(data))
            {
                OracleDBObj obj = new OracleDBObj();
                obj.CreateConnection();
                obj.CreateTransaction();
                try
                {
                    DALItemObj.OnDB = false;
                    DALItemObj.COUNTQTY = data.COUNTQTY;
                    DALItemObj.LOTNO = data.LOTNO;
                    DALItemObj.PRODUCT = data.PRODUCT;
                    DALItemObj.STOCKCHECK = data.STOCKCHECK;
                    DALItemObj.LOCATION = data.LOCATION;

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

                    obj.zTrans.Commit();
                    obj.CloseConnection();
                }
                catch (Exception ex)
                {
                    obj.zTrans.Rollback();
                    obj.CloseConnection();
                    ret = false;
                    _error = ex.Message;
                }
            }
            else
            {
                ret = false;
            }
            return ret;
        }
Exemplo n.º 12
0
        public bool UpdateData(string userID, CustomerTypeSearchData data)
        {
            bool ret = true;
            if (VeridateData(data))
            {

                OracleDBObj obj = new OracleDBObj();
                obj.CreateConnection();
                obj.CreateTransaction();
                try
                {
                    DALObj.GetDataByLOID(data.LOID, obj.zTrans);
                    DALObj.LOID = data.LOID;
                    DALObj.NAME = data.NAME.Trim();
                    DALObj.DESCRIPTION = data.DESCRIPTION.Trim();
                    DALObj.ACTIVE = data.ACTIVE.Trim();
                    DALObj.CODE = data.CODE.Trim();
                    DALObj.DISCOUNT = data.DISCOUNT;
                    DALObj.LOWERPRICE = data.LOWERPRICE;

                    if (DALObj.OnDB)
                        ret = DALObj.UpdateCurrentData(userID, obj.zTrans);
                    else
                        ret = DALObj.InsertCurrentData(userID, obj.zTrans);

                    if (ret)
                    {
                        obj.zTrans.Commit();
                        obj.CloseConnection();
                    }
                    else
                    {
                        _error= DALObj.ErrorMessage;
                    }
                }
                catch (Exception ex)
                {
                    obj.zTrans.Rollback();
                    obj.CloseConnection();
                    ret = false;
                    throw new ApplicationException(ex.Message);
                }
            }
            else
                ret = false;
            return ret;
        }
Exemplo n.º 13
0
        public bool UpdateStockOutOtherStatus(ArrayList arrData, string status, string userID)
        {
            bool ret = true;
            OracleDBObj obj = new OracleDBObj();
            obj.CreateConnection();
            obj.CreateTransaction();
            try
            {
                for (int i = 0; i < arrData.Count; i++)
                {
                    //if (status == Constz.Requisition.Status.Approved.Code)
                    //{
                    //    if (GetStockOutItem(arrData[i].ToString()).Rows.Count == 0)
                    //    {
                    //        throw new ApplicationException("äÁèÊÒÁÒö͹ØÁѵÔÃÒ¡ÒÃä´é à¹×èͧ¨Ò¡ºÒ§ÃÒ¡ÒÃäÁèä´éÃкØÊÔ¹¤éÒ");
                    //    }
                    //    StockoutWHData data = GetData(Convert.ToDouble(arrData[i]));
                    //    if (data.CUSTOMER == 0) throw new ApplicationException("äÁèÊÒÁÒö͹ØÁѵÔÃÒ¡ÒÃä´é à¹×èͧ¨Ò¡ºÒ§ÃÒ¡ÒÃäÁèä´éÃкØÅÙ¡¤éÒ");
                    //    if (data.DUEDATE.Year == 1) throw new ApplicationException("äÁèÊÒÁÒö͹ØÁѵÔÃÒ¡ÒÃä´é à¹×èͧ¨Ò¡ºÒ§ÃÒ¡ÒÃäÁèä´é¡Ó˹´Çѹ·ÕèÊè§ÊÔ¹¤éÒ");
                    //}
                    DALObj.OnDB = false;
                    DALObj.GetDataByLOID(Convert.ToDouble(arrData[i]), obj.zTrans);

                    if (DALObj.DOCTYPE == Constz.DocType.ReqRawPD.LOID)
                    {
                        ret = DALObj.UpdatePDProductStatus(Convert.ToDouble(DALObj.PRODUCTLOID), Constz.Requisition.Status.RW.Code, userID, obj.zTrans);
                        if (!ret) throw new ApplicationException(DALObj.ErrorMessage);
                        else
                        {
                            ret = DALObj.UpdatePDOrderStatus(Convert.ToDouble(DALObj.PRODUCTLOID), Constz.Requisition.Status.RW.Code, userID, obj.zTrans);
                            if (!ret) throw new ApplicationException(DALObj.ErrorMessage);

                        }
                    }
                    DALObj.STATUS = Constz.Requisition.Status.Approved.Code;
                    ret = DALObj.UpdateCurrentData(userID, obj.zTrans);

                    if (!ret) throw new ApplicationException(DALObj.ErrorMessage);
                    ret = DALObj.CutStock(Convert.ToDouble(arrData[i]), 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;
        }
Exemplo n.º 14
0
        public bool CommitData(string userID, StockoutWHData data)
        {
            bool ret = true;
            OracleDBObj obj = new OracleDBObj();
            obj.CreateConnection();
            obj.CreateTransaction();
            try
            {
                UpdateData(userID, data, obj.zTrans);
                DALObj.OnDB = false;

                ret = DALObj.CutStock(_LOID, 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;
        }
Exemplo n.º 15
0
        public bool SubmitStockOut(string userID, double stockOut)
        {
            bool ret = true;
            OracleDBObj obj = new OracleDBObj();
            obj.CreateConnection();
            obj.CreateTransaction();
            try
            {
                DALObj.OnDB = false;
                DALObj.GetDataByLOID(stockOut, obj.zTrans);
                if (DALObj.STATUS == Constz.Requisition.Status.Waiting.Code)
                {
                    DALObj.STATUS = Constz.Requisition.Status.Approved.Code;

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

                    RequisitionDAL rDAL = new RequisitionDAL();
                    rDAL.GetDataByLOID(DALObj.REFLOID, obj.zTrans);
                    rDAL.ACTIVE = Constz.ActiveStatus.InActive;

                    ret = rDAL.UpdateCurrentData(userID, obj.zTrans);
                    if (!ret) throw new ApplicationException(rDAL.ErrorMessage);

                    ret = DALItemObj.UpdateStatusByStockOut(stockOut, DALObj.STATUS, userID, obj.zTrans);
                    if (!ret) throw new ApplicationException(DALItemObj.ErrorMessage);

                    ret = DALObj.CutStock(LOID, 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;
        }
Exemplo n.º 16
0
        public bool UpdateStockinReturnStatus(ArrayList arrData, string userID)
        {
            bool ret = true;
            OracleDBObj obj = new OracleDBObj();
            obj.CreateConnection();
            obj.CreateTransaction();
            try
            {
                for (int i = 0; i < arrData.Count; i++)
                {
                    if (GetItem(Convert.ToDouble(arrData[i])).Rows.Count == 0)
                    {
                        throw new ApplicationException("äÁèÊÒÁÒö͹ØÁѵÔÃÒ¡ÒÃä´é à¹×èͧ¨Ò¡ºÒ§ÃÒ¡ÒÃäÁèä´éÃкØÊÔ¹¤éÒ");
                    }
                    StockinReturnData data = GetData(Convert.ToDouble(arrData[i]));

                    DALObj.OnDB = false;
                    DALObj.GetDataByLOID(Convert.ToDouble(arrData[i]), obj.zTrans);
                    if (DALObj.STATUS == Constz.StockinReturn.Status.Waiting.Code)
                    {
                        DALObj.STATUS = Constz.StockinReturn.Status.Approved.Code;
                        ret = DALObj.UpdateCurrentData(userID, obj.zTrans);
                        if (!ret) throw new ApplicationException(DALObj.ErrorMessage);

                        StockInDAL sDAL = new StockInDAL();
                        ret = sDAL.CutStock(DALObj.LOID, userID, obj.zTrans);
                        if (!ret) throw new ApplicationException(sDAL.ErrorMessage);
                    }
                    StockInItemDAL itemDAL = new StockInItemDAL();
                    ret = itemDAL.UpdateStatusByStockIn(Convert.ToDouble(arrData[i]), Constz.StockinReturn.Status.Approved.Code, userID, obj.zTrans);
                    if (!ret) throw new ApplicationException(itemDAL.ErrorMessage);
                }
                obj.zTrans.Commit();
                obj.CloseConnection();
            }
            catch (Exception ex)
            {
                obj.zTrans.Rollback();
                obj.CloseConnection();
                ret = false;
                _error = ex.Message;
            }
            return ret;
        }
Exemplo n.º 17
0
        private bool UpdatePackage(string UserID, DataTable tempTable, double ProductBarcodeLOID)
        {
            bool ret = true;
            OracleDBObj objDB = new OracleDBObj();

            objDB.CreateConnection();
            objDB.CreateTransaction();
            
            string sqlDelete = "DELETE FROM PACKAGE WHERE MAINPRODUCT = " + ProductBarcodeLOID;
            OracleDB.ExecNonQueryCmd(sqlDelete, objDB.zTrans);

            for (int i = 0; i < tempTable.Rows.Count; i++)
            {
                PackageDAL pkDAL = new PackageDAL();
                pkDAL.MAINPRODUCT = ProductBarcodeLOID;
                pkDAL.SUBPRODUCT = Convert.ToDouble(tempTable.Rows[i]["LOID"]);
                pkDAL.QTY = Convert.ToDouble(tempTable.Rows[i]["QUANTITY"]);
                pkDAL.PRICE = Convert.ToDouble(tempTable.Rows[i]["PRICE"]);
                pkDAL.UNIT = Convert.ToDouble(tempTable.Rows[i]["PUNIT"]);

                ret = pkDAL.InsertCurrentData(UserID, objDB.zTrans);
                if (ret == false)
                {
                    _error = pkDAL.ErrorMessage;
                    break;
                }
            }

            if (ret == false)
            {
                objDB.zTrans.Rollback();
                objDB.CloseConnection();
                return ret;
            }
            else
            {
                objDB.zTrans.Commit();
                objDB.CloseConnection();
                return ret;
            }
        }
Exemplo n.º 18
0
        public bool UpdateData(string userID, StockoutBasketData data)
        {
            bool ret = true;
            if (ValidateData(data))
            {
                OracleDBObj obj = new OracleDBObj();
                obj.CreateConnection();
                obj.CreateTransaction();
                try
                {
                    DALObj.OnDB = false;
                    DALObj.GetDataByLOID(data.LOID, obj.zTrans);

                    DALObj.CODE = data.CODE;
                    DALObj.CHECKDATE = data.CHECKDATE;
                    DALObj.PRODUCT = data.PRODUCT;
                    DALObj.QTY = data.QTY;
                    if (data.STOCKINDATE.Year != 1)
                    {
                        DALObj.STOCKINDATE = data.STOCKINDATE;
                    }
                    DALObj.REMARK = data.REMARK;
                    DALObj.TYPE = data.TYPE;
                    DALObj.UNIT = data.UNIT;
                    DALObj.STATUS = data.STATUS;
                    DALObj.LOTNO = data.LOTNO;
                    DALObj.WAREHOUSE = data.WAREHOUSE;

                    if (DALObj.OnDB)
                    {
                        ret = DALObj.UpdateCurrentData(userID, obj.zTrans);
                        if (!ret) throw new ApplicationException(DALObj.ErrorMessage);

                    }
                    else
                    {
                        DALObj.STATUS = data.STATUS;
                        ret = DALObj.InsertCurrentData(userID, obj.zTrans);
                        if (!ret) throw new ApplicationException(DALObj.ErrorMessage);
                    }

                    _LOID = DALObj.LOID;
                    

                    BasketItemDAL itemDAL = new BasketItemDAL();
                    itemDAL.DeleteDataByBasket(data.LOID, obj.zTrans);
                    for (Int16 i = 0; i < data.ITEM.Count; ++i)
                    {
                        BasketItemData item = (BasketItemData)data.ITEM[i];
                        itemDAL.BASKET = DALObj.LOID;
                        itemDAL.PRODUCT = item.PRODUCT;
                        itemDAL.UNIT = item.UNIT;
                        itemDAL.LOTNO = item.LOTNO;
                        itemDAL.PACKAGE = item.PACKAGE;
                        itemDAL.QTY = item.QTY;
                        itemDAL.PRODUCTSTOCK = item.PRODUCTSTOCK;

                        itemDAL.OnDB = false;
                        ret = itemDAL.InsertCurrentData(userID, obj.zTrans);
                        if (!ret) throw new ApplicationException(itemDAL.ErrorMessage);
                    }

                    if (data.STATUS == Constz.Requisition.Status.Approved.Code)
                    {
                        ret = DALObj.CutStockBasket(DALObj.LOID, 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;
                }
            }
            else
                ret = false;
            return ret;
        }
Exemplo n.º 19
0
        public bool DeleteStockCheckItem(double loid)
        {
            bool ret = true;
            OracleDBObj obj = new OracleDBObj();
            obj.CreateConnection();
            obj.CreateTransaction();
            try
            {
                DALItemObj.GetDataByLOID(loid, obj.zTrans);
                ret = DALItemObj.DeleteCurrentData(obj.zTrans);
                if (!ret) throw new ApplicationException(DALItemObj.ErrorMessage);

                obj.zTrans.Commit();
                obj.CloseConnection();
            }
            catch (Exception ex)
            {
                obj.zTrans.Rollback();
                obj.CloseConnection();
                ret = false;
                _error = ex.Message;
            }
            return ret;
        }
Exemplo n.º 20
0
        public bool DeleteData(ArrayList arrLOID)
        {
            bool ret = true;
            OracleDBObj objDB = new OracleDBObj();

            objDB.CreateConnection();
            objDB.CreateTransaction();

            try
            {
                foreach (double LOID in arrLOID)
                {
                    CustomerDAL oDAL = new CustomerDAL();
                    oDAL.GetDataByLOID(LOID, objDB.zTrans);
                    oDAL.DeleteCurrentData(objDB.zTrans);
                }
                objDB.zTrans.Commit();
                ret = true;
            }
            catch(Exception ex)
            {
                objDB.zTrans.Rollback();
                _error = ex.Message;
                ret = false;
            }

            objDB.CloseConnection();
            return ret;
        }
Exemplo n.º 21
0
        public bool GetCustomerDiscount(double customer, double totalPrice)
        {
            bool ret = true;
            _DISCOUNT = 0;
            
            OracleDBObj obj = new OracleDBObj();
            obj.CreateConnection();
            obj.CreateTransaction();
            try
            {
                CustomerDAL cDAL = new CustomerDAL();
                cDAL.GetDataByLOID(customer, obj.zTrans);
                if (cDAL.OnDB)
                {
                    if (cDAL.EFDATE.Date <= DateTime.Today && DateTime.Today <= cDAL.EPDATE.Date)
                        _DISCOUNT = DALObj.GetMemberDiscount(cDAL.MEMBERTYPE, totalPrice, obj.zTrans);
                }

                obj.zTrans.Commit();
                obj.CloseConnection();
            }
            catch (Exception ex)
            {
                obj.zTrans.Rollback();
                obj.CloseConnection();
                ret = false;
                _error = ex.Message;
            }
            return ret;
        }
Exemplo n.º 22
0
        public bool UpdateData(string userID, ReturnRequestData data)
        {

            // ####### UPDATE REQUISITION
            bool ret = true;
            if (ValidateData(data))
            {
                OracleDBObj obj = new OracleDBObj();
                obj.CreateConnection();
                obj.CreateTransaction();

                //if (data.LOID != 0)
                //{
                //    // update old requisition
                //    DALObj.GetDataByLOID(data.LOID, obj.zTrans);
                //}
                //else
                //{
                //    DALObj.STATUS = data.STATUS;
                //    DALObj.ACTIVE = data.ACTIVE;
                //    DALObj.REFTABLE = "PDPRODUCT";
                //    DALObj.REFLOID = data.VPLOID;
                //    DALObj.LOTNO = data.LOTNO;
                //    DALObj.WAREHOUSE = data.WAREHOUSE;
                //}

                try
                {
                    DALObj.OnDB = false;
                    DALObj.GetDataByLOID(data.LOID, obj.zTrans);

                    DALObj.CODE = data.CODE;
                    DALObj.REQDATE = data.REQDATE;
                    DALObj.STATUS = data.STATUS;
                    DALObj.ACTIVE = data.ACTIVE;
                    DALObj.REFTABLE = data.REFTABLE;
                    DALObj.REFLOID = data.REFLOID;
                    DALObj.LOTNO = data.LOTNO;
                    DALObj.WAREHOUSE = data.WAREHOUSE;
                    DALObj.REMARK = data.REMARK;
                    DALObj.REQUISITIONTYPE = data.REQUISITIONTYPE;


                    if (DALObj.OnDB)
                        ret = DALObj.UpdateCurrentData(userID, obj.zTrans);
                    else
                        ret = DALObj.InsertCurrentData(userID, obj.zTrans);

                    _LOID = DALObj.LOID;
                    if (!ret)
                    {
                        throw new ApplicationException(DALObj.ErrorMessage);
                    }


                    // ############ UPDATE ITEM
                    ProductMaterial itemDAL = new ProductMaterial();
                    itemDAL.DeleteCurrentDataByREQ(DALObj.LOID, obj.zTrans);
                    for (Int16 i = 0; i < data.ITEM.Count; ++i)
                    {
                        itemDAL = new ProductMaterial();
                        ReturnItemData item = (ReturnItemData)data.ITEM[i];
                        itemDAL.REQUISITION = DALObj.LOID;
                        itemDAL.PRODUCT = item.PDLOID;
                        itemDAL.MASTER = item.MASTER;
                        itemDAL.UNIT = item.UNIT;
                        itemDAL.USEQTY = item.USEQTY;
                        itemDAL.WASTEQTYMAT = item.WASTEQTYMAT;
                        itemDAL.RETURNQTY = item.RETURNQTY;
                        itemDAL.ACTIVE = Constz.ActiveStatus.Active;

                        //                        itemDAL.OnDB = false;
                        ret = itemDAL.InsertCurrentData(userID, obj.zTrans);
                        if (!ret) throw new ApplicationException(itemDAL.ErrorMessage);
                    }
                    obj.zTrans.Commit();
                    obj.CloseConnection();
                }
                catch (Exception ex)
                {
                    obj.zTrans.Rollback();
                    obj.CloseConnection();
                    ret = false;
                    _error = ex.Message;
                }
            }
            else
                ret = false;
            return ret;
        }
Exemplo n.º 23
0
        public bool UpdateData(string userID, StockInFGData data)
        {
            bool ret = true;
            if (ValidateData(data))
            {
                OracleDBObj obj = new OracleDBObj();
                obj.CreateConnection();
                obj.CreateTransaction();
                try
                {
                    UpdateData(userID, data, obj.zTrans);

                    obj.zTrans.Commit();
                    obj.CloseConnection();
                }
                catch (Exception ex)
                {
                    obj.zTrans.Rollback();
                    obj.CloseConnection();
                    ret = false;
                    _error = ex.Message;
                }
            }
            else
                ret = false;
            return ret;
        }
Exemplo n.º 24
0
        //public bool CopyPDRequest(string userID, double loidSource)
        //{
        //    PDReserveData data = GetData(loidSource);
        //    DataTable itemList = GetPDItem(data.LOID);
        //    ArrayList arr = new ArrayList();
        //    foreach (DataRow dRow in itemList.Rows)
        //    {
        //        PDReserveItemData idata = new PDReserveItemData();
        //        idata.MASTER = Convert.ToDouble(dRow["MASTER"]);
        //        idata.ACTIVE = Constz.ActiveStatus.Active;
        //        arr.Add(idata);
        //    }
        //    data.ITEM = arr;
        //    DALObj.OnDB = false;
        //    data.LOID = 0;
        //    data.CODE = "";
        //    data.STATUS = Constz.Requisition.Status.Waiting.Code;
        //    //data.ACTIVE = Constz.ActiveStatus.Active;
        //    //data.ORDERTYPE = Constz.OrderType.PO.Code;
        //    return UpdateData(userID, data);
        //}

        public bool CommitData(string userID, ReturnRequestData data)
        {
            bool ret = true;
            if (ValidateData(data))
            {
                OracleDBObj obj = new OracleDBObj();
                obj.CreateConnection();
                obj.CreateTransaction();
                try
                {
                    UpdateData(userID, data);

                    ret = DALObj.CutStockRequisition(_LOID, 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;
                }
            }
            else
                ret = false;
            return ret;
        }
Exemplo n.º 25
0
        public bool UpdateStockInStatus(double loid, string status, string userID)
        {
            bool ret = true;
            OracleDBObj obj = new OracleDBObj();
            obj.CreateConnection();
            obj.CreateTransaction();
            try
            {
                DALObj.OnDB = false;
                DALObj.GetDataByLOID(loid, obj.zTrans);
                DALObj.STATUS = status;
                ret = DALObj.UpdateCurrentData(userID, obj.zTrans);
                if (!ret) throw new ApplicationException(DALObj.ErrorMessage);

                ret = DALItemObj.UpdateStatusByStockIn(DALObj.LOID, DALObj.STATUS, userID, obj.zTrans);
                if (!ret) throw new ApplicationException(DALItemObj.ErrorMessage);

                ret = DALObj.CutStock(loid, 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;
        }
Exemplo n.º 26
0
         public bool UpdateData(string userID, QCAnalysisData data)
         {

             // ####### UPDATE REQUISITION
             bool ret = true;
             if (ValidateData(data))
             {
                 OracleDBObj obj = new OracleDBObj();
                 obj.CreateConnection();
                 obj.CreateTransaction();

                 if (data.STLOID != 0)
                 {
                     // update old requisition
                     DALObj.GetDataByLOID(data.STLOID, obj.zTrans);
                 }
                 else
                 {
                     DALObj.STLOID = data.STLOID;
                 }

                 try
                 {
                     DALObj.OnDB = false;
                     DALObj.GetDataByLOID(data.STLOID, obj.zTrans);

                     //DALObj.CODE = data.CODE;
                     //DALObj.REQDATE = data.REQDATE;
                     //DALObj.REMARK = data.REMARK;


                     if (DALObj.OnDB)
                         ret = DALObj.UpdateCurrentData(userID, obj.zTrans);
                     else
                         ret = DALObj.InsertCurrentData(userID, obj.zTrans);

                     _STLOID = DALObj.STLOID;
                     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;
                 }
             }
             else
                 ret = false;
             return ret;
         }
Exemplo n.º 27
0
        public bool UpdateStockInFNStatus(ArrayList arrData, string status, string userID)
        {
            bool ret = true;
            OracleDBObj obj = new OracleDBObj();
            obj.CreateConnection();
            obj.CreateTransaction();
            try
            {
                for (int i = 0; i < arrData.Count; i++)
                {
                    if (status == Constz.Requisition.Status.Finish.Code)
                    {
                        if (GetStockInItem(Convert.ToDouble(arrData[i])).Rows.Count == 0)
                        {
                            throw new ApplicationException("äÁèÊÒÁÒö͹ØÁѵÔÃÒ¡ÒÃä´é à¹×èͧ¨Ò¡ºÒ§ÃÒ¡ÒÃäÁèä´éÃкØÊÔ¹¤éÒ");
                        }
                    }
                    DALObj.OnDB = false;
                    DALObj.GetDataByLOID(Convert.ToDouble(arrData[i]), obj.zTrans);
                    DALObj.STATUS = Constz.Requisition.Status.Finish.Code;
                    ret = DALObj.UpdateCurrentData(userID, obj.zTrans);
                    if (!ret) throw new ApplicationException(DALObj.ErrorMessage);

                    ret = DALObj.CutStock(Convert.ToDouble(arrData[i]), 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;
        }
Exemplo n.º 28
0
         public bool SubmitQCStockIn(ArrayList arrData, string userID)
         {
             bool ret = true;
             OracleDBObj obj = new OracleDBObj();
             obj.CreateConnection();
             obj.CreateTransaction();
             try
             {
                 for (int i =0; i<arrData.Count; ++i)
                 {
                     string[] str = arrData[i].ToString().Split('#');
                     if (str[1] == "STOCKIN")
                     {
                         StDAL.OnDB = false;
                         StDAL.GetDataByLOID(Convert.ToDouble(str[0]), obj.zTrans);
                         StockInItemDAL _itemDAL = new StockInItemDAL();
                         if (_itemDAL.GetDataList("WHERE STOCKIN = " + StDAL.LOID.ToString() + " AND QCRESULT NOT IN ('" + Constz.QCResult.Fail.Code + "', '" + Constz.QCResult.Pass.Code + "') ", obj.zTrans).Rows.Count == 0)
                             throw new ApplicationException("ÃкؼšÒõÃǨÊͺÃÒ¡ÒÃàÅ¢·Õè " + StDAL.CODE + " ãËé¤Ãº·Ø¡ÃÒ¡ÒÃ");
                         if (StDAL.STATUS == Constz.Requisition.Status.QC.Code)
                         {
                             StDAL.STATUS = Constz.Requisition.Status.Approved.Code;
                             ret = StDAL.UpdateCurrentData(userID, obj.zTrans);
                             if (!ret) throw new ApplicationException(StDAL.ErrorMessage);
                         }
                     }
                     else
                     {
                         PoDAl.OnDB = false;
                         PoDAl.GetDataByLOID(Convert.ToDouble(str[0]), obj.zTrans);
                         PDProductDAL _itemDAL = new PDProductDAL();
                         if (_itemDAL.GetDataList("WHERE PDPRODUCT = " + PoDAl.LOID.ToString() + " AND QCRESULT NOT IN ('" + Constz.QCResult.Fail.Code + "', '" + Constz.QCResult.Pass.Code + "') ", obj.zTrans).Rows.Count == 0)
                             throw new ApplicationException("ÃкؼšÒõÃǨÊͺÃÒ¡ÒÃàÅ¢·Õè " + PoDAl.CODE + " ãËé¤Ãº·Ø¡ÃÒ¡ÒÃ");
                         if (PoDAl.STATUS == Constz.Requisition.Status.QC.Code)
                         {
                             PoDAl.STATUS = Constz.Requisition.Status.Approved.Code;
                             ret = PoDAl.UpdateCurrentData(userID, obj.zTrans);
                             if (!ret) throw new ApplicationException(PoDAl.ErrorMessage);

                             ret = PoDAl.CutStock(Convert.ToDouble(str[0]), userID, obj.zTrans);
                             if (!ret) throw new ApplicationException(PoDAl.ErrorMessage);
                         }
                     }
                 }
                 obj.zTrans.Commit();
                 obj.CloseConnection();
             }
             catch (Exception ex)
             {
                 obj.zTrans.Rollback();
                 obj.CloseConnection();
                 ret = false;
                 _error = ex.Message;
             }
             return ret;
         }
Exemplo n.º 29
0
        public bool InsertNewBatchNo(string userID, StockCheckData data)
        {
            bool ret = true;
            StockCheckDAL itemDAL = new StockCheckDAL();
            OracleDBObj obj = new OracleDBObj();
            obj.CreateTransaction();
            try
            {
                itemDAL.BATCHNO = GenNewBatchNo(data.WAREHOUSE, obj.zTrans);
                itemDAL.CHECKDATE = DateTime.Now;
                itemDAL.WAREHOUSE = data.WAREHOUSE;
                itemDAL.STATUS = Constz.Requisition.Status.Waiting.Code;

                ret = itemDAL.InsertCurrentData(userID, obj.zTrans);
                if (!ret) throw new ApplicationException(itemDAL.ErrorMessage);
                _LOID = itemDAL.LOID;

                obj.zTrans.Commit();
                obj.CloseConnection();
            }
            catch (Exception ex)
            {
                ret = false;
                obj.zTrans.Rollback();
                obj.CloseConnection();
            }
            return ret;
        }
Exemplo n.º 30
0
        public bool CommitData(string userID, StockinReturnData data)
        {
            bool ret = true;
            bool cutstock = true;
            bool custockinreturnlost = true;
            if (ValidateData(data))
            {
                OracleDBObj obj = new OracleDBObj();
                obj.CreateConnection();
                obj.CreateTransaction();
                try
                {
                    DALObj.OnDB = false;
                    DALObj.GetDataByLOID(data.LOID, obj.zTrans);
                    cutstock = (DALObj.STATUS == Constz.Requisition.Status.Waiting.Code);
                    custockinreturnlost = cutstock;
                    UpdateData(userID, data, obj.zTrans);
                    if (cutstock)
                    {
                        StockInDAL sDAL = new StockInDAL();
                        ret = sDAL.CutStock(DALObj.LOID, userID, obj.zTrans);
                        if (!ret) _error = sDAL.ErrorMessage;
                    }

                    if (custockinreturnlost)
                    {
                        StockInDAL sDAL = new StockInDAL();
                        ret = sDAL.CutStockInReturnLost(DALObj.LOID, userID, obj.zTrans);
                        if (!ret) _error = sDAL.ErrorMessage;
                    }
                    obj.zTrans.Commit();
                    obj.CloseConnection();
                }
                catch (Exception ex)
                {
                    obj.zTrans.Rollback();
                    obj.CloseConnection();
                    ret = false;
                    _error = ex.Message;
                }
            }
            else
                ret = false;
            return ret;
        }