示例#1
0
        private double InsertProductBarcode(string UserID, BasketData bkData, double ProductMaster)
        {
             bool ret = true;
             ProductBarcodeDAL bDAL = new ProductBarcodeDAL();
             bDAL.PRODUCTMASTER = ProductMaster;
             bDAL.ABBNAME = bkData.ABBNAME;
             bDAL.BARCODE = bkData.BARCODE;
             bDAL.UNIT = bkData.UNITBASKET;
             bDAL.COST = bkData.COST;
             bDAL.PRICE = bkData.PRICE;
             bDAL.ISVAT = bkData.ISVAT;
             bDAL.ISDISCOUNT = bkData.ISDISCOUNT;
             bDAL.ISREFUND = bkData.ISREFUND;
             bDAL.ACTIVE = bkData.ACTIVE;
             bDAL.STDPRICE = bkData.PRICE;
             bDAL.MULTIPLY = 1;
             bDAL.ISEDIT = "Y";
             bDAL.ISDEFAULT = "Y";
             ret = bDAL.InsertCurrentData(UserID, null);
             if (ret == false)
             {                   
                 string sqlDelete = "DELETE FROM PRODUCTMASTER WHERE LOID = " + ProductMaster;
                 OracleDB.ExecNonQueryCmd(sqlDelete);

                 _error = bDAL.ErrorMessage;
                 return 0;
             }
             else
             {
               return bDAL.LOID;
             } 
        }
示例#2
0
        public bool UpdateItemData(string userID, ProductSearchData data)
        {
            bool ret = true;
            
            OracleDBObj obj = new OracleDBObj();
            obj.CreateConnection();
            obj.CreateTransaction();
            try
            {
                ProductBarcodeDAL itemDAL = new ProductBarcodeDAL();
                ProductBarcodeDAL itemDAL2 = new ProductBarcodeDAL();
                ProductBarcodeDAL itemDAL3 = new ProductBarcodeDAL();
                //itemDAL.DeleteDataByProductMasterExceptDefault(data.LOID, obj.zTrans);
                itemDAL.UpdateActiveByProductMasterExceptDefault(data.LOID, "0", userID, obj.zTrans);
                for (Int16 i = 1; i < data.ITEM.Count; ++i)
                {
                    ProductBarcodeData item = (ProductBarcodeData)data.ITEM[i];
                    itemDAL.OnDB = false;
                    itemDAL.ACTIVE = "";
                    itemDAL.GetDataByBARCODE(item.BARCODE, obj.zTrans);
                    if (itemDAL.ACTIVE != Constz.ActiveStatus.Active)
                    {
                        itemDAL2.GetDataByABBNAME(item.ABBNAME.Trim(), obj.zTrans);
                        if (itemDAL2.ACTIVE == Constz.ActiveStatus.Active)
                        {
                            throw new ApplicationException("ª×èÍÂèÍ " + item.ABBNAME + " ¹ÕéÁÕáÅéÇ");
                        }
                        itemDAL3.GetDataByABBUNIT(item.LOID,item.UNIT, obj.zTrans);
                        if (itemDAL3.ACTIVE == Constz.ActiveStatus.Active)
                        {
                            throw new ApplicationException("ª×èÍ˹èÇ«éÓ");
                        }

                        itemDAL.BARCODE = item.BARCODE;
                        itemDAL.PRODUCTMASTER = data.LOID;
                        itemDAL.ABBNAME = item.ABBNAME;
                        itemDAL.UNIT = item.UNIT;
                        itemDAL.COST = item.COST;
                        itemDAL.PRICE = item.PRICE;
                        itemDAL.STDPRICE = item.STDPRICE;
                        itemDAL.ISDISCOUNT = "0";
                        itemDAL.ISVAT = "1";
                        itemDAL.PACKSIZE = item.PACKSIZE;
                        itemDAL.PACKSIZEUNIT = item.UNITPACK;
                        itemDAL.ISEDIT = "Y";
                        itemDAL.ISREFUND = "N";
                        itemDAL.ACTIVE = Convert.ToString(item.ACTIVE);
                        itemDAL.MULTIPLY = item.MULTIPLY;
                        itemDAL.ISDEFAULT = "N";

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

                        if (!ret) throw new ApplicationException(itemDAL.ErrorMessage);
                    }
                    else
                    {
                        throw new ApplicationException("ºÒÃìâ¤é´ " + item.BARCODE + " ¹ÕéÁÕáÅéÇ");
                    }
                }
                _LOID = data.LOID;
                obj.zTrans.Commit();
                obj.CloseConnection();
            }
            catch (Exception ex)
            {
                obj.zTrans.Rollback();
                obj.CloseConnection();
                ret = false;
                _error = ex.Message;
            }

            return ret;
        }