Exemplo n.º 1
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool UpdateOrder(EmsModel.OrderInfo Model)
        {
            EmsModel.OrderEquipDetail MOD = new EmsModel.OrderEquipDetail();
            MOD.OrderId = Model.Id;
            List <EmsModel.OrderEquipDetail> list = new EmsDAL.OrderEquipDetail().GetListByPage(MOD, 1, 999);

            return(dal.UpdateOrder(Model, list));
        }
Exemplo n.º 2
0
        /// <summary>
        /// 获取订单数据 分页
        /// </summary>
        /// <param name="Mod">查询条件</param>
        /// <param name="pageIndex">当前页</param>
        /// <param name="pageSize">页容量,每页显示条数</param>
        /// <returns></returns>
        public EmsModel.JsonModel GetJsonModel(EmsModel.OrderInfo Mod, int pageIndex, int pageSize)
        {
            List <EmsModel.OrderInfo> modList = GetListByPage(Mod, ((pageIndex - 1) * pageSize) + 1, (pageIndex * pageSize));
            //定义分页数据实体
            PagedDataModel <EmsModel.OrderInfo> pagedDataModel = null;
            //定义JSON标准格式实体中
            JsonModel jsonModel = null;

            if (modList.Count > 0)
            {
                var list = modList;
                //总条数
                int rowCount = GetListByPageCount(Mod);
                //总页数
                int pageCount = (int)Math.Ceiling(rowCount * 1.0 / pageSize);
                //将数据封装到PagedDataModel分页数据实体中
                pagedDataModel = new PagedDataModel <EmsModel.OrderInfo>()
                {
                    PageCount = pageCount,
                    PagedData = list,
                    PageIndex = pageIndex,
                    PageSize  = pageSize,
                    RowCount  = rowCount
                };
                //将分页数据实体封装到JSON标准实体中
                jsonModel = new JsonModel()
                {
                    Data    = pagedDataModel,
                    Msg     = "成功",
                    Status  = "ok",
                    BackUrl = ""
                };
                return(jsonModel);
            }
            else
            {
                jsonModel = new JsonModel()
                {
                    Status = "no",
                    Msg    = "失败"
                };
                return(jsonModel);
            }
        }
Exemplo n.º 3
0
        public bool Lend(string strOrder, string orderNO, EmsModel.OrderInfo mod)
        {
            List <EmsModel.OrderEquipDetail> listModer = new List <EmsModel.OrderEquipDetail>();

            //"6,9,碳刷,18#6,9,碳刷,20"
            string[] sArr = strOrder.Split('#');
            for (int i = 0; i < sArr.Length; i++)
            {
                string[] sArr2 = sArr[i].Split(',');
                EmsModel.OrderEquipDetail model = new EmsModel.OrderEquipDetail();
                model.InventoryKindId = Convert.ToInt32(sArr2[0]);
                //model.OrderId =Convert.ToInt32( sArr2[1]);
                model.InstrumentEquip = sArr2[1];
                model.EquipDetailName = sArr2[1];
                model.EquipId         = sArr2[2];
                model.Type            = 1;

                listModer.Add(model);
            }
            int typeNo = 1;

            return(dal.UpdateOrderLend(listModer, orderNO, typeNo, 1, mod));
        }
Exemplo n.º 4
0
        public EmsModel.JsonModel CreateOrder(Hashtable ht)
        {
            try
            {
                //string[] Str = ht["YSelectStr"].ToString().Split(',');//

                //订单编号前缀
                string prefix = "";
                if (ht["Type"].ToString() == "0")
                {
                    prefix = "SY";
                }
                else if (ht["Type"].ToString() == "1")
                {
                    prefix = "YJ";
                }

                EmsDAL.OrderEquipDetail ModelOrderEquipDetail = new EmsDAL.OrderEquipDetail();

                //订单赋值
                EmsModel.OrderInfo ModelOrderInfo = new EmsModel.OrderInfo();

                ModelOrderInfo.OrderNo      = prefix;
                ModelOrderInfo.LoanName     = ht["LoanName"].ToString();
                ModelOrderInfo.ExperimentId = Convert.ToInt32(ht["ExperimentId"]);
                ModelOrderInfo.Type         = Convert.ToByte(ht["Type"]);
                ModelOrderInfo.Status       = 0;
                ModelOrderInfo.Creator      = ht["Creator"].ToString();
                ModelOrderInfo.CreateTime   = DateTime.Now;
                ModelOrderInfo.IsDelete     = 0;

                //修改实验“是否生成订单”状态
                EmsDAL.PlanExperiment   DALPE   = new EmsDAL.PlanExperiment();
                EmsModel.PlanExperiment ModelPE = DALPE.GetData(ht["ExperimentId"].ToString())[0];
                ModelPE.Status = 1;//将实验状态赋值为“已生成订单”

                //事务
                using (SqlTransaction trans = dal.GetTran())
                {
                    try
                    {
                        //添加订单
                        int orderId = dal.Add(trans, ModelOrderInfo);
                        if (orderId <= 0)
                        {
                            //回滚
                            trans.Rollback();
                            //定义JSON标准格式实体中
                            JsonModel jsonModel1 = new JsonModel();
                            jsonModel1.Status = "no";
                            jsonModel1.Msg    = "订单生成失败";

                            return(jsonModel1);
                        }
                        //修改订单编号
                        ModelOrderInfo.Id      = orderId;
                        ModelOrderInfo.OrderNo = prefix + DateTime.Now.ToString("yyMMddHHmmss") + orderId;
                        int UpdateReturn = dal.Update(trans, ModelOrderInfo);
                        if (UpdateReturn != 1)
                        {
                            //回滚
                            trans.Rollback();
                            //定义JSON标准格式实体中
                            JsonModel jsonModel1 = new JsonModel();
                            jsonModel1.Status = "no";
                            jsonModel1.Msg    = "订单生成失败";

                            return(jsonModel1);
                        }
                        //修改实验状态
                        int UpdatePEReturn = DALPE.Update(trans, ModelPE);
                        if (UpdatePEReturn != 1)
                        {
                            //回滚
                            trans.Rollback();
                            //定义JSON标准格式实体中
                            JsonModel jsonModel1 = new JsonModel();
                            jsonModel1.Status = "no";
                            jsonModel1.Msg    = "订单生成失败";

                            return(jsonModel1);
                        }

                        #region 添加订单设备详情

                        ////生成订单
                        //int AddCount = 0;
                        //int SuccessCount = 0;
                        ////循环添加设备
                        //foreach (string item in Str)
                        //{
                        //    int EquipKindId = Convert.ToInt32(item.Substring(0, item.IndexOf("-")));
                        //    int Count = Convert.ToInt32(item.Substring(item.IndexOf("-") + 1, item.IndexOf(":") - item.IndexOf("-") - 1));
                        //    string InstrumentEquip = item.Substring(item.IndexOf(":") + 1);

                        //    //更新需要添加的设备数量
                        //    AddCount += Count;
                        //    //每个设备添加一条数据
                        //    for (int i = 0; i < Count; i++)
                        //    {
                        //        //model赋值
                        //        EmsModel.OrderEquipDetail model = new EmsModel.OrderEquipDetail();
                        //        model.OrderId = orderId;
                        //        model.InventoryKindId = EquipKindId;
                        //        model.EquipId = "";
                        //        model.InstrumentEquip = InstrumentEquip;
                        //        model.EquipDetailName = "";
                        //        model.Type = 0;
                        //        int ret = ModelOrderEquipDetail.Add(trans, model);
                        //        if (ret > 0)
                        //        {
                        //            SuccessCount++;
                        //        }
                        //    }

                        //}
                        //if (AddCount != SuccessCount)
                        //{
                        //    //回滚
                        //    trans.Rollback();
                        //    //定义JSON标准格式实体中
                        //    JsonModel jsonModel1 = new JsonModel();
                        //    jsonModel1.Status = "no";
                        //    jsonModel1.Msg = "订单生成失败";

                        //    return jsonModel1;
                        //}
                        //else
                        //{
                        //    //提交
                        //    trans.Commit();
                        //}
                        #endregion
                        //提交
                        trans.Commit();
                    }
                    catch (Exception)
                    {
                        //回滚
                        trans.Rollback();
                        throw;
                    }
                }

                //定义JSON标准格式实体中
                JsonModel jsonModel = new JsonModel();
                jsonModel.Status = "ok";
                jsonModel.Msg    = "订单生成成功";

                return(jsonModel);
            }
            catch (Exception ex)
            {
                JsonModel jsonModel = new JsonModel();
                jsonModel.Status = "error";
                jsonModel.Msg    = ex.ToString();
                return(jsonModel);
            }
        }