Ejemplo n.º 1
0
 public t_purchaseOrder Selectt_purchaseOrder(t_purchaseOrder objt_purchaseOrder)
 {
     try
     {
         strquery = @"select * from t_purchaseOrder where no = '" + objt_purchaseOrder.no + "'";
         DataRow drType = u_DBConnection.ReturnDataRow(strquery);
         if (drType != null)
         {
             objt_purchaseOrder.no            = drType["no"].ToString();
             objt_purchaseOrder.locationId    = drType["locationId"].ToString();
             objt_purchaseOrder.reqLocationId = drType["reqLocationId"].ToString();
             objt_purchaseOrder.pReqNo        = drType["pReqNo"].ToString();
             objt_purchaseOrder.poMethod      = drType["poMethod"].ToString();
             objt_purchaseOrder.date          = DateTime.Parse(drType["date"].ToString());
             objt_purchaseOrder.supplierId    = drType["supplierId"].ToString();
             objt_purchaseOrder.DeliveryDate  = DateTime.Parse(drType["DeliveryDate"].ToString());
             objt_purchaseOrder.DLocationID   = drType["DLocationID"].ToString();
             objt_purchaseOrder.noOfItems     = decimal.Parse(drType["noOfItems"].ToString());
             objt_purchaseOrder.noOfPeaces    = decimal.Parse(drType["noOfPeaces"].ToString());
             objt_purchaseOrder.grossAmount   = decimal.Parse(drType["grossAmount"].ToString());
             objt_purchaseOrder.remarks       = drType["remarks"].ToString();
             objt_purchaseOrder.isSaved       = bool.Parse(drType["isSaved"].ToString());
             objt_purchaseOrder.isProcessed   = bool.Parse(drType["isProcessed"].ToString());
             objt_purchaseOrder.processDate   = DateTime.Parse(drType["processDate"].ToString());
             objt_purchaseOrder.processUser   = drType["processUser"].ToString();
             objt_purchaseOrder.triggerVal    = int.Parse(drType["triggerVal"].ToString());
             return(objt_purchaseOrder);
         }
         return(null);
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Ejemplo n.º 2
0
        public HttpResponseMessage AuditPurOrderForm(t_purchaseOrder obj)
        {
            DateTime dt = DateTime.Now;

            obj.Status        = 2;
            obj.ConfirmTime   = dt;
            obj.ConfirmUserID = (int)userInfo.UserID;
            var saveObj = SaveForm(obj);

            if (saveObj.result == true)
            {
                return(Json(true, saveObj.message, saveObj.data));
            }
            else
            {
                throw new DomainException("审核失败!");
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Saves a record to the t_purchaseOrder table.
        /// </summary>
        public Boolean Savet_purchaseOrderSP(t_purchaseOrder t_purchaseOrder, int formMode)
        {
            SqlCommand scom;
            bool       retvalue = false;

            try
            {
                scom             = new SqlCommand();
                scom.CommandType = CommandType.StoredProcedure;
                scom.CommandText = "T_purchaseOrderSave";

                scom.Parameters.Add("@no", SqlDbType.VarChar, 20).Value            = t_purchaseOrder.no;
                scom.Parameters.Add("@locationId", SqlDbType.VarChar, 20).Value    = t_purchaseOrder.locationId;
                scom.Parameters.Add("@reqLocationId", SqlDbType.VarChar, 20).Value = t_purchaseOrder.reqLocationId;
                scom.Parameters.Add("@pReqNo", SqlDbType.VarChar, 20).Value        = t_purchaseOrder.pReqNo;
                scom.Parameters.Add("@poMethod", SqlDbType.VarChar, 20).Value      = t_purchaseOrder.poMethod;
                scom.Parameters.Add("@date", SqlDbType.DateTime, 8).Value          = t_purchaseOrder.date;
                scom.Parameters.Add("@supplierId", SqlDbType.VarChar, 20).Value    = t_purchaseOrder.supplierId;
                scom.Parameters.Add("@DeliveryDate", SqlDbType.DateTime, 8).Value  = t_purchaseOrder.DeliveryDate;
                scom.Parameters.Add("@DLocationID", SqlDbType.VarChar, 20).Value   = t_purchaseOrder.DLocationID;
                scom.Parameters.Add("@noOfItems", SqlDbType.Decimal, 9).Value      = t_purchaseOrder.noOfItems;
                scom.Parameters.Add("@noOfPeaces", SqlDbType.Decimal, 9).Value     = t_purchaseOrder.noOfPeaces;
                scom.Parameters.Add("@grossAmount", SqlDbType.Decimal, 9).Value    = t_purchaseOrder.grossAmount;
                scom.Parameters.Add("@remarks", SqlDbType.VarChar, 100).Value      = t_purchaseOrder.remarks;
                scom.Parameters.Add("@isSaved", SqlDbType.Bit, 1).Value            = t_purchaseOrder.isSaved;
                scom.Parameters.Add("@isProcessed", SqlDbType.Bit, 1).Value        = t_purchaseOrder.isProcessed;
                scom.Parameters.Add("@processDate", SqlDbType.DateTime, 8).Value   = t_purchaseOrder.processDate;
                scom.Parameters.Add("@processUser", SqlDbType.VarChar, 20).Value   = t_purchaseOrder.processUser;
                scom.Parameters.Add("@triggerVal", SqlDbType.Int, 4).Value         = t_purchaseOrder.triggerVal;
                scom.Parameters.Add("@InsMode", SqlDbType.Int).Value  = formMode; // For insert
                scom.Parameters.Add("@RtnValue", SqlDbType.Int).Value = 0;

                u_DBConnection dbcon = new u_DBConnection();
                retvalue = dbcon.RunQuery(scom);
                return(retvalue);
            }
            catch (Exception ex)
            {
                throw (ex);
            }
        }
Ejemplo n.º 4
0
        public List <t_purchaseOrder> SelectT_purchaseOrderMulti(t_purchaseOrder objt_purchaseOrder2)
        {
            List <t_purchaseOrder> retval = new List <t_purchaseOrder>();

            try
            {
                strquery = @"select * from t_purchaseOrder where no = '" + objt_purchaseOrder2.no + "'";
                DataTable dtt_purchaseOrder = u_DBConnection.ReturnDataTable(strquery, CommandType.Text);
                foreach (DataRow drType in dtt_purchaseOrder.Rows)
                {
                    if (drType != null)
                    {
                        t_purchaseOrder objt_purchaseOrder = new t_purchaseOrder();
                        objt_purchaseOrder.no            = drType["no"].ToString();
                        objt_purchaseOrder.locationId    = drType["locationId"].ToString();
                        objt_purchaseOrder.reqLocationId = drType["reqLocationId"].ToString();
                        objt_purchaseOrder.pReqNo        = drType["pReqNo"].ToString();
                        objt_purchaseOrder.poMethod      = drType["poMethod"].ToString();
                        objt_purchaseOrder.date          = DateTime.Parse(drType["date"].ToString());
                        objt_purchaseOrder.supplierId    = drType["supplierId"].ToString();
                        objt_purchaseOrder.DeliveryDate  = DateTime.Parse(drType["DeliveryDate"].ToString());
                        objt_purchaseOrder.DLocationID   = drType["DLocationID"].ToString();
                        objt_purchaseOrder.noOfItems     = decimal.Parse(drType["noOfItems"].ToString());
                        objt_purchaseOrder.noOfPeaces    = decimal.Parse(drType["noOfPeaces"].ToString());
                        objt_purchaseOrder.grossAmount   = decimal.Parse(drType["grossAmount"].ToString());
                        objt_purchaseOrder.remarks       = drType["remarks"].ToString();
                        objt_purchaseOrder.isSaved       = bool.Parse(drType["isSaved"].ToString());
                        objt_purchaseOrder.isProcessed   = bool.Parse(drType["isProcessed"].ToString());
                        objt_purchaseOrder.processDate   = DateTime.Parse(drType["processDate"].ToString());
                        objt_purchaseOrder.processUser   = drType["processUser"].ToString();
                        objt_purchaseOrder.triggerVal    = int.Parse(drType["triggerVal"].ToString());
                        retval.Add(objt_purchaseOrder);
                    }
                }
                return(retval);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Ejemplo n.º 5
0
        private dynamic SaveForm(t_purchaseOrder obj)
        {
            using (TransactionScope transaction = new TransactionScope())
            {
                DateTime dt = DateTime.Now;

                t_purchase_order objItem = new t_purchase_order()
                {
                    POID            = obj.POID,
                    PostDate        = obj.PostDate,
                    PurchaserID     = obj.PurchaserID,
                    Remark          = obj.Remark,
                    Status          = obj.Status,
                    SupplierID      = obj.SupplierID,
                    TruckID         = obj.TruckID,
                    UpdateTime      = obj.UpdateTime,
                    UpdateUserID    = obj.UpdateUserID,
                    BillDate        = obj.BillDate,
                    BillType        = obj.BillType,
                    Code            = obj.Code,
                    ConfirmTime     = obj.ConfirmTime,
                    ConfirmUserID   = obj.ConfirmUserID,
                    CorpID          = obj.CorpID,
                    CreateTime      = obj.CreateTime,
                    CreateUserID    = obj.CreateUserID,
                    DriverID        = obj.DriverID,
                    IsStockFinished = obj.IsStockFinished
                };

                DBHelper <t_purchase_order> dbhelp_purOrder = new DBHelper <t_purchase_order>();


                //事务
                var result = 0;
                var Item   = db.t_purchase_order.Where(w => w.Code == objItem.Code && w.CorpID == userInfo.CorpID);
                try
                {
                    if (objItem.POID == 0)
                    {
                        string Code = objItem.Code;
                        if (Code == "" || Code == null)
                        {
                            result = AutoIncrement.AutoIncrementResult("PurchaseOrder", out Code);
                        }

                        objItem.CreateTime   = dt;
                        objItem.BillDate     = dt;
                        objItem.CreateUserID = (int)userInfo.UserID;
                        objItem.CorpID       = userInfo.CorpID;
                        objItem.Code         = Code;
                        objItem.Status       = 1;
                        if (Item.ToList().Count() > 0)
                        {
                            throw new Exception("账号重复!");
                        }
                        result = result + dbhelp_purOrder.Add(objItem);
                    }
                    else
                    {
                        objItem.CorpID       = userInfo.CorpID;
                        objItem.UpdateTime   = dt;
                        objItem.UpdateUserID = (int)userInfo.UserID;
                        if (Item.ToList().Count() > 1)
                        {
                            throw new Exception("账号重复!");
                        }
                        result = result + dbhelp_purOrder.Update(objItem);
                    }

                    //删除并保存明细
                    DBHelper <t_purchase_order_detail> dbhelp_purOderDetail = new DBHelper <t_purchase_order_detail>();
                    List <int>         ItemList      = new List <int>();
                    List <int>         UomList       = new List <int>();
                    List <t_itemprice> itempriceList = new List <t_itemprice>();
                    foreach (var item in obj.OrderDetail)
                    {
                        item.CorpID       = userInfo.CorpID;
                        item.POID         = objItem.POID;
                        item.UpdateTime   = dt;
                        item.UpdateUserID = (int)userInfo.UserID;
                        ItemList.Add(item.ItemID);
                        UomList.Add(item.UomID);
                        itempriceList.Add(new t_itemprice
                        {
                            CorpID     = userInfo.CorpID,
                            SuppCustID = objItem.SupplierID,
                            ItemID     = item.ItemID,
                            UomID      = item.UomID,
                            LastPrice  = item.UnitAmount,
                            UpdateTime = dt,
                            TargetType = 1
                        });
                    }
                    //删除明细
                    result = result + dbhelp_purOderDetail.RemoveList(w => w.POID == objItem.POID);
                    //添加明细
                    result = result + dbhelp_purOderDetail.AddList(obj.OrderDetail);

                    //删除最后价格
                    DBHelper <t_itemprice> dbhelp_itemprice = new DBHelper <t_itemprice>();
                    result = result + dbhelp_itemprice.RemoveList(w => w.TargetType == 1 && w.CorpID == userInfo.CorpID && ItemList.Contains(w.ItemID) && UomList.Contains(w.UomID) && w.SuppCustID == objItem.SupplierID);
                    //添加最后价格
                    result = result + dbhelp_itemprice.AddList(itempriceList.ToArray());

                    //提交事务
                    transaction.Complete();
                    return(new { result = true, message = "保存成功!", data = new { POID = objItem.POID } });
                }
                catch (Exception ex)
                {
                    throw new DomainException("保存失败!");
                }
            }
        }
Ejemplo n.º 6
0
        public HttpResponseMessage SavePurOrderForm(t_purchaseOrder obj)
        {
            //using (TransactionScope transaction = new TransactionScope())
            //{
            //    DateTime dt = DateTime.Now;

            //    t_purchase_order objItem = new t_purchase_order()
            //    {
            //        POID = obj.POID,
            //        PostDate = obj.PostDate,
            //        PurchaserID = obj.PurchaserID,
            //        Remark = obj.Remark,
            //        Status = obj.Status,
            //        SupplierID = obj.SupplierID,
            //        TruckID = obj.TruckID,
            //        UpdateTime = obj.UpdateTime,
            //        UpdateUserID = obj.UpdateUserID,
            //        BillDate = obj.BillDate,
            //        BillType = obj.BillType,
            //        Code = obj.Code,
            //        ConfirmTime = obj.ConfirmTime,
            //        ConfirmUserID = obj.ConfirmUserID,
            //        CorpID = obj.CorpID,
            //        CreateTime = obj.CreateTime,
            //        CreateUserID = obj.CreateUserID,
            //        DriverID = obj.DriverID,
            //        IsStockFinished = obj.IsStockFinished
            //    };

            //    DBHelper<t_purchase_order> dbhelp_purOrder = new DBHelper<t_purchase_order>();


            //    //事务
            //    var result = 0;
            //    var Item = db.t_purchase_order.Where(w => w.Code == objItem.Code && w.CorpID == userInfo.CorpID);
            //    try
            //    {
            //        if (objItem.POID == 0)
            //        {
            //            string Code = objItem.Code;
            //            if (Code == "" || Code == null)
            //            {
            //                result = AutoIncrement.AutoIncrementResult("PurchaseOrder", out Code);
            //            }

            //            objItem.CreateTime = dt;
            //            objItem.BillDate = dt;
            //            objItem.CreateUserID = (int)userInfo.UserID;
            //            objItem.CorpID = userInfo.CorpID;
            //            objItem.Code = Code;
            //            objItem.Status = 1;
            //            if (Item.ToList().Count() > 0)
            //            {
            //                throw new Exception("账号重复!");
            //            }
            //            result = result + dbhelp_purOrder.Add(objItem);
            //        }
            //        else
            //        {
            //            objItem.CorpID = userInfo.CorpID;
            //            objItem.UpdateTime = dt;
            //            objItem.UpdateUserID = (int)userInfo.UserID;
            //            if (Item.ToList().Count() > 1)
            //            {
            //                throw new Exception("账号重复!");
            //            }
            //            result = result + dbhelp_purOrder.Update(objItem);
            //        }

            //        //删除并保存明细
            //        DBHelper<t_purchase_order_detail> dbhelp_purOderDetail = new DBHelper<t_purchase_order_detail>();
            //        List<int> ItemList = new List<int>();
            //        List<int> UomList = new List<int>();
            //        List<t_itemprice> itempriceList = new List<t_itemprice>();
            //        foreach (var item in obj.OrderDetail)
            //        {
            //            item.CorpID = userInfo.CorpID;
            //            item.POID = objItem.POID;
            //            item.UpdateTime = dt;
            //            item.UpdateUserID = (int)userInfo.UserID;
            //            ItemList.Add(item.ItemID);
            //            UomList.Add(item.UomID);
            //            itempriceList.Add(new t_itemprice {
            //                CorpID = userInfo.CorpID,
            //                SuppCustID=objItem.SupplierID,
            //                ItemID=item.ItemID,
            //                UomID=item.UomID,
            //                LastPrice=item.UnitAmount,
            //                UpdateTime=dt,
            //                TargetType=1
            //            });
            //        }
            //        //删除明细
            //        result = result + dbhelp_purOderDetail.RemoveList(w => w.POID == objItem.POID);
            //        //添加明细
            //        result = result + dbhelp_purOderDetail.AddList(obj.OrderDetail);

            //        //删除最后价格
            //        DBHelper<t_itemprice> dbhelp_itemprice = new DBHelper<t_itemprice>();
            //        result = result + dbhelp_itemprice.RemoveList(w => w.TargetType==1 && w.CorpID==userInfo.CorpID && ItemList.Contains(w.ItemID) && UomList.Contains(w.UomID) && w.SuppCustID==objItem.SupplierID);
            //        //添加最后价格
            //        result = result + dbhelp_itemprice.AddList(itempriceList.ToArray());

            //        //提交事务
            //        transaction.Complete();
            //        return Json(true, "保存成功!", new { POID = objItem.POID });
            //    }
            //    catch (Exception ex)
            //    {
            //        return Json(false, "保存失败!" + ex.Message);
            //    }
            //}

            var saveObj = SaveForm(obj);

            if (saveObj.result == true)
            {
                return(Json(true, saveObj.message, saveObj.data));
            }
            else
            {
                return(Json(false, saveObj.message));
            }
        }