protected void Page_Load(object sender, EventArgs e)
        {
            StockCheck ent = null;

            switch (RequestActionString)
            {
            case "delete":
                ent = this.GetTargetData <StockCheck>();
                ent.DoDelete();
                break;

            case "batchdelete":
                DoBatchDelete();
                break;

            case "submit":
                StartFlow();
                break;

            case "AutoExecuteFlow":
                Task task = Task.FindAllByProperties(Task.Prop_WorkflowInstanceID, this.RequestData.Get <string>("FlowId"))[0];
                //自动执行,关键代码
                Aim.WorkFlow.WorkFlow.AutoExecute(task);
                this.PageState.Add("TaskId", task.ID);
                break;

            default:
                DoSelect();
                break;
            }
        }
        public List <StockCheck> ConvertDBToList()
        {
            DataTable         dt          = new DataTable();
            List <StockCheck> stockChecks = new List <StockCheck>();

            try
            {
                OpenConnection();
                string queryString = @"Select * from PHIEUKIEMKHO";

                SqlCommand command = new SqlCommand(queryString, conn);
                command.ExecuteNonQuery();
                SqlDataAdapter adapter = new SqlDataAdapter(command);

                adapter.Fill(dt);
            }
            catch
            {
            }
            finally
            {
                CloseConnection();
            }
            for (int i = 0; i < dt.Rows.Count; i++)
            {
                StockCheck employee = new StockCheck(
                    int.Parse(dt.Rows[i].ItemArray[0].ToString()),
                    DateTime.Parse(dt.Rows[i].ItemArray[1].ToString())
                    );
                stockChecks.Add(employee);
            }
            return(stockChecks);
        }
Example #3
0
        public bool AddBillToDatabase(StockCheck stockCheck)
        {
            try
            {
                OpenConnection();
                string     queryString = "Insert Into PHIEUKIEMKHO Values(@id, @date)";
                SqlCommand command     = new SqlCommand(queryString, conn);
                command.Parameters.AddWithValue("@id", stockCheck.Id);
                command.Parameters.AddWithValue("@date", stockCheck.Datestock);

                int rs = command.ExecuteNonQuery();
                if (rs != 1)
                {
                    return(false);
                }
                else
                {
                    return(true);
                }
            }
            catch (Exception e)
            {
                MessageBox.Show("Thêm thất bại!" + e, "Thông báo", MessageBoxButton.OK, MessageBoxImage.Error);
                return(false);
            }
            finally
            {
                CloseConnection();
            }
        }
Example #4
0
 public ReturnType AddStockCheck(StockCheck stockCheck)
 {
     try
     {
         using (AladingEntities alading = new AladingEntities(AppSettings.GetConnectionString()))
         {
             alading.AddToStockCheck(stockCheck);
             if (alading.SaveChanges() == 1)
             {
                 return(ReturnType.Success);
             }
             else
             {
                 return(ReturnType.PropertyExisted);
             }
         }
     }
     catch (SqlException sex)
     {
         return(ReturnType.ConnFailed);
     }
     catch (Exception ex)
     {
         return(ReturnType.OthersError);
     }
 }
Example #5
0
        public void RunStockCheck(string id)
        {
            LinkSelect linkS = new LinkSelect();

            linkS.TableNames.Add("stockMaterialSettlementDetail");
            linkS.TableNames.Add("stockMaterialSettlement");
            linkS.LinkConds.Add("stockMaterialSettlementDetail.smsId=stockMaterialSettlement.id");
            linkS.TableNames.Add("indent");
            linkS.LinkConds.Add("stockMaterialSettlementDetail.iId=indent.id");
            linkS.TableNames.Add("material");
            linkS.LinkConds.Add("indent.mId=material.id");
            linkS.TableNames.Add("materialName");
            linkS.LinkConds.Add("material.mnId=materialName.id");
            linkS.TableNames.Add("materialModel");
            linkS.LinkConds.Add("material.mmId=materialModel.id");
            linkS.TableNames.Add("materialKind");
            linkS.LinkConds.Add("materialName.mkId=materialKind.id");
            linkS.Viewfields.Add("materialKind.sort");
            linkS.Viewfields.Add("materialName.[name]");
            linkS.Viewfields.Add("materialModel.model");
            linkS.Viewfields.Add("stockMaterialSettlementDetail.[sum] as money");
            linkS.Viewfields.Add("stockMaterialSettlementDetail.count as suttle");
            linkS.Viewfields.Add("indent.unitPrice");
            linkS.Conds.Add("stockMaterialSettlement.id=" + id);
            DataSet ds = linkS.LeftLinkOpen();

            //SqlHelper helper = new SqlHelper();
            //String sql = "Select voitureInfo.[no] as sort,stockContract.[name],stockNote.iId as 合同明细编号,materialName.[name] as 材料名称,materialModel.model,stockNote.grossWeight as 车辆毛重,stockNote.tare as 车辆皮重,stockNote.suttle,site1.site as 起运地,site2.site as 止运地,stockNote.inputdate as 日期时间,stockNote.remark as 备注,stockNote.barCode as 条形码,unitPrice,unitPrice * stockNote.suttle as money From stockMaterialNoteCorresponding Left Outer Join stockNote ON stockMaterialNoteCorresponding.snId=stockNote.id Left Outer Join stockMaterialSettlementDetail ON stockMaterialNoteCorresponding.smsdId=stockMaterialSettlementDetail.id Left Outer Join stockMaterialSettlement ON stockMaterialSettlementDetail.smsId=stockMaterialSettlement.id Left Outer Join stockContract ON stockMaterialSettlement.scId=stockContract.id Left Outer Join voitureInfo ON stockNote.viId=voitureInfo.id Left Outer Join transportUnit ON voitureInfo.tuId=transportUnit.id Left Outer Join site site1 ON stockNote.sId1=site1.id Left Outer Join site site2 ON stockNote.sId2=site2.id Left Outer Join transportGoodsInformationCorresponding ON stockNote.tgicId=transportGoodsInformationCorresponding.id Left Outer Join transportContract ON transportGoodsInformationCorresponding.tcId=transportContract.id Left Outer Join indent ON stockNote.iId=indent.id Left Outer Join material ON indent.mId=material.id Left Outer Join materialName ON material.mnId=materialName.id Left Outer Join materialModel ON material.mmId=materialModel.id where 1=1  ";
            //System.Collections.ArrayList oArrayList = new System.Collections.ArrayList();
            //oArrayList.Add(sql);
            //DataSet ds = helper.QueryForDateSet(oArrayList);

            StockCheck oStockCheck = new StockCheck();

            oStockCheck.Source = ds;
            CReportTools tools = new CReportTools();
            DataTable    dt    = ds.Tables[0];
            Decimal      money = 0;

            for (int i = 0; i < dt.Rows.Count; i++)
            {
                money += Convert.ToDecimal(dt.Rows[i]["money"]);
            }
            oStockCheck.SumMoney    = tools.ToUpper(money);
            oStockCheck.AccountNum  = id.ToString();
            oStockCheck.ContractNum = "100086";
            oStockCheck.CoName      = "中百科技有限公司";
            oStockCheck.Num         = "1111";
            oStockCheck.InvoiceNo   = "0001";
            oStockCheck.Supplier    = "中百";
            oStockCheck.Telephone   = "138888888";
            oStockCheck.Auditor     = "刘淼";
            oStockCheck.Examine     = "bbb";
            oStockCheck.Approve     = "ccc";
            oStockCheck.AuditorYmd  = "2008年5月21号";
            oStockCheck.ExamineYmd  = "2008年5月22号";
            oStockCheck.ApproveYmd  = "2008年5月23号";
            oStockCheck.ShowReport();
        }
        private void DoBatchDelete()
        {
            IList <object> idList = RequestData.GetList <object>("IdList");

            if (idList != null && idList.Count > 0)
            {
                StockCheck.DoBatchDelete(idList.ToArray());
            }
        }
Example #7
0
        public ApiResultModel <int> AddStockCheck(StockCheck model)
        {
            var result = new ApiResultModel <int>();

            _stockCheckRepository.Add(model);
            _stockCheckRepository.SaveChanges();

            result.Code = ApiResultCode.Success;
            return(result);
        }
Example #8
0
        static void Main()
        {
            Console.WriteLine("Start legacy application");

            IStockCheck stockCheck = new StockCheck();

            stockCheck.Monitor(100);

            Console.WriteLine("End legacy application");
        }
Example #9
0
        string type = String.Empty; // 对象类型
        protected void Page_Load(object sender, EventArgs e)
        {
            op   = RequestData.Get <string>("op");
            id   = RequestData.Get <string>("id");
            type = RequestData.Get <string>("type");
            StockCheck     scEnt   = null;
            IList <String> strList = RequestData.GetList <string>("data");

            switch (RequestActionString)
            {
            case "update":
                scEnt = this.GetMergedData <StockCheck>();
                scEnt.DoUpdate();
                ProcessDetail(strList, scEnt);
                break;

            case "create":
                scEnt       = this.GetPostedData <StockCheck>();
                scEnt.State = "未结束";
                scEnt.DoCreate();
                ProcessDetail(strList, scEnt);
                break;

            case "delete":
                scEnt = this.GetTargetData <StockCheck>();
                scEnt.DoDelete();
                return;

            default:
                if (op != "c" && op != "cs")
                {
                    if (!String.IsNullOrEmpty(id))
                    {
                        scEnt = StockCheck.Find(id);
                        SetFormData(scEnt);
                        IList <StockCheckDetail> scdEnts = StockCheckDetail.FindAllByProperty("StockCheckId", id);
                        PageState.Add("DataList", scdEnts);
                    }
                }
                else
                {
                    PageState.Add("StockCheckNo", DataHelper.QueryValue("select SHHG_AimExamine.dbo.fun_getStockCheckNo()"));
                    this.PageState.Add("FlowEnum", SysEnumeration.GetEnumDictList("WorkFlow.Simple"));
                    if (RequestActionString == "submitfinish")
                    {
                        StockCheck pc = StockCheck.Find(this.RequestData.Get <string>("id"));
                        pc.State = "End";
                        // pc.InventoryState = this.RequestData.Get<string>("ApprovalState");
                        pc.Save();
                    }
                }
                break;
            }
        }
Example #10
0
        public void StartFlow(string formId)
        {
            string code = this.RequestData.Get <string>("FlowKey");

            Aim.WorkFlow.WorkflowTemplate ne = Aim.WorkFlow.WorkflowTemplate.FindAllByProperties(Aim.WorkFlow.WorkflowTemplate.Prop_Code, code)[0];
            //启动流程
            //表单路径,后面加上参数传入
            StockCheck scEnt   = StockCheck.Find(formId);
            string     formUrl = "/SaleManagement/StockCheckView.aspx?id=" + formId;
            Guid       guid    = Aim.WorkFlow.WorkFlow.StartWorkFlow(formId, formUrl, "盘点单【" + scEnt.StockCheckNo + "】申请人【" + scEnt.CreateName + "】", code, this.UserInfo.UserID, this.UserInfo.Name);

            //返回流程的Id
            this.PageState.Add("FlowId", guid.ToString());
        }
        private void OpenStockBillWindow(HomeWindow parameter)
        {
            this.homeWindow = parameter;
            CheckStockWindow checkStockWindow = new CheckStockWindow();

            checkStockWindow.txtDate.Text = DateTime.Now.ToString("dd/MM/yyyy");
            int id = StockCheckDAL.Instance.GetMaxId() + 1;

            checkStockWindow.txtIdStockBill.Text = id.ToString();
            checkStockWindow.txtGood.ItemsSource = getNameGood();
            StockCheck stockCheck = new StockCheck(id, DateTime.Now);

            StockCheckDAL.Instance.AddStockCheckToDatabase(stockCheck);
            checkStockWindow.ShowDialog();
        }
        public void StartFlow()
        {
            string     state = this.RequestData.Get <string>("state");
            string     id    = this.RequestData.Get <string>("Id");
            StockCheck pb    = StockCheck.Find(id);

            pb.State = state;
            pb.Save();
            string code = this.RequestData.Get <string>("FlowKey");

            //启动流程
            //表单路径,后面加上参数传入
            string formUrl = "/StockManagement/FrmInventoryView.aspx?op=u&&id=" + id;
            Guid   guid    = Aim.WorkFlow.WorkFlow.StartWorkFlow(id, formUrl, "仓库盘点异常审批(" + pb.StockCheckNo + ")[" + pb.CreateName + "]", code, this.UserInfo.UserID, this.UserInfo.Name);

            this.PageState.Add("FlowId", guid.ToString());
        }
Example #13
0
        protected void Page_Load(object sender, EventArgs e)
        {
            StockCheck ent = null;

            switch (RequestActionString)
            {
            case "delete":
                ent = this.GetTargetData <StockCheck>();
                ent.DoDelete();
                break;

            case "batchdelete":
                DoBatchDelete();
                break;

            case "SubmitExamine":
                string id = this.RequestData.Get <string>("Id");
                ent = StockCheck.Find(id);
                ent.WorkFlowState = RequestData.Get <string>("state");
                ent.ExamineResult = RequestData.Get <string>("ApprovalState");
                ent.DoUpdate();
                StartFlow(id);
                break;

            case "AutoExecuteFlow":
                Task task = Task.FindAllByProperties(Task.Prop_WorkflowInstanceID, this.RequestData.Get <string>("FlowId"))[0];
                //自动执行,关键代码
                Aim.WorkFlow.WorkFlow.AutoExecute(task);
                this.PageState.Add("TaskId", task.ID);
                break;

            default:
                if (RequestData.Get <string>("optype") == "getChildData")
                {
                    string stockCheckId             = RequestData.Get <string>("StockCheckId");
                    IList <StockCheckDetail> scdEnt = StockCheckDetail.FindAllByProperty("StockCheckId", stockCheckId);
                    PageState.Add("DetailList", scdEnt);
                }
                else
                {
                    DoSelect();
                }
                break;
            }
        }
Example #14
0
        private void ProcessDetail(IList <string> strList, StockCheck ent)
        {
            StockCheckDetail scdEnt = null;

            foreach (string str in strList)
            {
                JObject json = JsonHelper.GetObject <JObject>(str);
                scdEnt = StockCheckDetail.Find(json.Value <string>("Id"));
                if (json.Value <int>("StockCheckQuantity") >= 0)
                {
                    scdEnt.StockCheckQuantity = json.Value <int>("StockCheckQuantity");
                    if (scdEnt.StockQuantity > scdEnt.StockCheckQuantity)
                    {
                        scdEnt.StockCheckResult = "盘亏";
                    }
                    if (scdEnt.StockQuantity < scdEnt.StockCheckQuantity)
                    {
                        scdEnt.StockCheckResult = "盘赢";
                    }
                    if (scdEnt.StockQuantity == scdEnt.StockCheckQuantity)
                    {
                        scdEnt.StockCheckResult = "正常";
                        scdEnt.StockCheckState  = "盘点结束";
                    }
                    scdEnt.DoUpdate();
                }
            }
            //1  如果所有的盘点明细都正常 则把盘点单的状态改为已结束
            SearchCriterion.AddSearch("StockCheckResult", "正常", SearchModeEnum.NotEqual);
            IList <StockCheckDetail> scdEnts = StockCheckDetail.FindAll(SearchCriterion);

            if (scdEnts.Count == 0)
            {
                ent.State = "已结束"; ent.Result = "正常";
            }
            else
            {
                ent.Result = "异常";
            }
            ent.DoUpdate();
        }
Example #15
0
        protected override object GetEditObject(GridRecord row)
        {
            if (_InventoryFacade == null)
            {
                _InventoryFacade = new InventoryFacade(this.DataProvider);
            }
            if (_WarehouseFacade == null)
            {
                _WarehouseFacade = new WarehouseFacade(base.DataProvider);
            }
            string checkNo = row.Items.FindItemByKey("CheckNo").Text;

            StockCheck check = (StockCheck)_WarehouseFacade.GetStockCheck(checkNo);

            if (check != null)
            {
                return(check);
            }

            return(null);
        }
        private void DoSelect()
        {
            if (!SearchCriterion.Orders.Exists(en => en.PropertyName == "CreateTime"))
            {
                SearchCriterion.Orders.Add(new OrderCriterionItem("CreateTime", false));
            }
            string state = "未结束";
            string temp  = RequestData.Get <string>("State");

            if (!string.IsNullOrEmpty(temp))
            {
                state = temp;
            }
            if (state == "未结束")
            {
                SearchCriterion.AddSearch("State", "已结束", SearchModeEnum.NotEqual);
            }
            else
            {
                SearchCriterion.AddSearch("State", state);
            }
            ents = StockCheck.FindAll(SearchCriterion);
            PageState.Add("DataList", ents);
        }
Example #17
0
        private void ProcessDetail(IList <string> strList, StockCheck ent)
        {
            IList <StockCheckDetail> scEnts = StockCheckDetail.FindAllByProperty("StockCheckId", ent.Id);

            foreach (StockCheckDetail tent in scEnts)
            {
                tent.DoDelete();
            }
            StockCheckDetail scdEnt = null;

            foreach (string str in strList)
            {
                JObject json = JsonHelper.GetObject <JObject>(str);
                scdEnt = new StockCheckDetail();
                scdEnt.StockCheckId    = ent.Id;
                scdEnt.ProductId       = json.Value <string>("ProductId");
                scdEnt.ProductName     = json.Value <string>("ProductName");
                scdEnt.ProductCode     = json.Value <string>("ProductCode");
                scdEnt.ProductPcn      = json.Value <string>("ProductPcn");
                scdEnt.StockQuantity   = json.Value <int>("StockQuantity");
                scdEnt.StockCheckState = json.Value <string>("StockCheckState");
                scdEnt.DoCreate();
            }
        }
Example #18
0
        private void CreateLog()
        {
            IList <InWarehouseDetailDetail> iwddEnts = InWarehouseDetailDetail.FindAll();//入库

            foreach (InWarehouseDetailDetail iwddEnt in iwddEnts)
            {
                StockLog    slEnt = new StockLog();
                InWarehouse iwEnt = null;
                if (!string.IsNullOrEmpty(iwddEnt.InWarehouseDetailId))
                {
                    slEnt.InOrOutDetailId = iwddEnt.InWarehouseDetailId;
                    InWarehouseDetail iwdEnt = InWarehouseDetail.Find(iwddEnt.InWarehouseDetailId);
                    iwEnt = InWarehouse.Find(iwdEnt.InWarehouseId);
                }
                else
                {
                    slEnt.InOrOutDetailId = iwddEnt.OtherInWarehouseDetailId;
                    OtherInWarehouseDetail oiwdEnt = OtherInWarehouseDetail.Find(iwddEnt.OtherInWarehouseDetailId);
                    iwEnt = InWarehouse.Find(oiwdEnt.InWarehouseId);
                }
                slEnt.InOrOutBillNo = iwEnt.InWarehouseNo;
                slEnt.OperateType   = "产品入库";
                slEnt.WarehouseId   = iwEnt.WarehouseId;
                slEnt.WarehouseName = iwEnt.WarehouseName;
                //IList<StockInfo> siEnts = StockInfo.FindAllByProperties(StockInfo.Prop_ProductId, iwddEnt.ProductId, StockInfo.Prop_WarehouseId, iwEnt.WarehouseId);
                //if (siEnts.Count > 0)
                //{
                //    slEnt.StockQuantity = siEnts[0].StockQuantity;
                //}
                slEnt.Quantity  = iwddEnt.Quantity;
                slEnt.ProductId = iwddEnt.ProductId;
                Product pEnt = Product.TryFind(iwddEnt.ProductId);
                if (pEnt != null)
                {
                    slEnt.ProductName = pEnt.Name;
                    slEnt.ProductCode = pEnt.Code;
                    slEnt.ProductIsbn = pEnt.Isbn;
                    slEnt.ProductPcn  = pEnt.Pcn;
                    slEnt.CreateId    = iwddEnt.CreateId;
                    slEnt.CreateName  = iwddEnt.CreateName;
                    slEnt.CreateTime  = iwddEnt.CreateTime;
                    slEnt.DoCreate();
                }
            }
            //生成出库日志
            IList <DelieryOrderPart> dopEnts = DelieryOrderPart.FindAllByProperty(DelieryOrderPart.Prop_State, "已出库");

            foreach (DelieryOrderPart dopEnt in dopEnts)
            {
                StockLog slEnt = new StockLog();
                slEnt.InOrOutDetailId = dopEnt.Id;
                DeliveryOrder doEnt = DeliveryOrder.Find(dopEnt.DId);
                slEnt.InOrOutBillNo = doEnt.Number;
                slEnt.OperateType   = "产品出库";
                slEnt.WarehouseId   = doEnt.WarehouseId;
                slEnt.WarehouseName = doEnt.WarehouseName;
                //IList<StockInfo> siEnts = StockInfo.FindAllByProperties(StockInfo.Prop_ProductId, iwddEnt.ProductId, StockInfo.Prop_WarehouseId, iwEnt.WarehouseId);
                //if (siEnts.Count > 0)
                //{
                //    slEnt.StockQuantity = siEnts[0].StockQuantity;
                //}
                slEnt.Quantity = dopEnt.OutCount;
                if (!string.IsNullOrEmpty(dopEnt.ProductId))
                {
                    slEnt.ProductId = dopEnt.ProductId;
                    Product pEnt = Product.TryFind(dopEnt.ProductId);
                    if (pEnt != null)
                    {
                        slEnt.ProductName = pEnt.Name;
                        slEnt.ProductCode = pEnt.Code;
                        slEnt.ProductIsbn = pEnt.Isbn;
                        slEnt.ProductPcn  = pEnt.Pcn;
                        slEnt.CreateId    = dopEnt.CreateId;
                        slEnt.CreateName  = dopEnt.CreateName;
                        slEnt.CreateTime  = dopEnt.CreateTime;
                        slEnt.DoCreate();
                    }
                }
            }
            //盘点操作库存日志
            string sql = "select * from SHHG_AimExamine..StockCheckDetail where StockCheckResult!='正常' and StockCheckState='盘点结束'";
            IList <EasyDictionary> scdDics = DataHelper.QueryDictList(sql);

            foreach (EasyDictionary scdDic in scdDics)
            {
                StockLog slEnt = new StockLog();
                slEnt.InOrOutDetailId = scdDic.Get <string>("Id");
                StockCheck scEnt = StockCheck.Find(scdDic.Get <string>("StockCheckId"));
                slEnt.InOrOutBillNo = scEnt.StockCheckNo;
                slEnt.OperateType   = "库存盘点";
                slEnt.WarehouseId   = scEnt.WarehouseId;
                slEnt.WarehouseName = scEnt.WarehouseName;
                slEnt.StockQuantity = scdDic.Get <Int32>("StockQuantity");
                slEnt.Quantity      = scdDic.Get <Int32>("StockCheckQuantity") - scdDic.Get <Int32>("StockQuantity");
                slEnt.ProductId     = scdDic.Get <string>("ProductId");
                Product pEnt = Product.TryFind(slEnt.ProductId);
                if (pEnt != null)
                {
                    slEnt.ProductName = pEnt.Name;
                    slEnt.ProductCode = pEnt.Code;
                    slEnt.ProductIsbn = pEnt.Isbn;
                    slEnt.ProductPcn  = pEnt.Pcn;
                    slEnt.CreateId    = scEnt.CreateId;
                    slEnt.CreateName  = scEnt.CreateName;
                    slEnt.CreateTime  = scEnt.CreateTime;
                    slEnt.DoCreate();
                }
            }
        }
Example #19
0
        private void exportxmlbutton_Click(object sender, EventArgs e)
        {
            DateTime time1 = Convert.ToDateTime(this.dateTimePickerstart.Value.Date.ToString("yyyy/MM/dd"));
            DateTime time2 = Convert.ToDateTime(this.dateTimePickerend.Value.Date.ToString("yyyy/MM/dd"));

            if (DateTime.Compare(time1, time2) > 0) //判断日期大小
            {
                MessageBox.Show("开始日期大于结束");
                return;
            }

            string startTime = this.dateTimePickerstart.Value.ToString("yyyy/MM/dd");
            string endTime   = this.dateTimePickerend.Value.ToString("yyyy/MM/dd");

            OpeningStockClass openingstock  = new OpeningStockClass();
            List <StoreInit>  storeInitList = new List <StoreInit>();

            List <StockCheck> StockCheckList = new List <StockCheck>();

            string seq_no = DateTime.Now.ToString("yyyyMMdd") + "2005" + "1"; //日期+类型+序号

            string boxtype    = "2005";                                       //代码
            string flowstateg = "";
            string trade_code = "";
            string ems_no     = "";

            string status = "A";

            try
            {
                SqlConnection mConn = new SqlConnection(Constlist.ConStr);
                mConn.Open();

                SqlCommand cmd = new SqlCommand();
                cmd.Connection  = mConn;
                cmd.CommandType = CommandType.Text;

                //查询71bom
                Dictionary <string, string> _71bomDic = new Dictionary <string, string>();

                Dictionary <string, string> _71bomDescribeDic = new Dictionary <string, string>();//料号与描述对应
                cmd.CommandText = "select distinct material_mpn,material_vendor_pn,_description from LCFC71BOM_table";
                SqlDataReader querySdr = cmd.ExecuteReader();
                while (querySdr.Read())
                {
                    if (_71bomDic.ContainsKey(querySdr[0].ToString().Trim()) == false)
                    {
                        _71bomDic.Add(querySdr[0].ToString().Trim(), querySdr[1].ToString().Trim());
                    }

                    if (_71bomDescribeDic.ContainsKey(querySdr[0].ToString().Trim()) == false)
                    {
                        _71bomDescribeDic.Add(querySdr[0].ToString().Trim(), querySdr[2].ToString().Trim());
                    }
                }
                querySdr.Close();
                //查询物料对照表
                Dictionary <string, string> materialbomDic = new Dictionary <string, string>();
                cmd.CommandText = "select distinct custommaterialNo,vendormaterialNo from MBMaterialCompare";
                querySdr        = cmd.ExecuteReader();
                while (querySdr.Read())
                {
                    if (materialbomDic.ContainsKey(querySdr[0].ToString().Trim()) == false)
                    {
                        materialbomDic.Add(querySdr[0].ToString().Trim(), querySdr[1].ToString().Trim());
                    }
                }
                querySdr.Close();


                cmd.CommandText = "select indentifier, book_number from company_fixed_table";
                querySdr        = cmd.ExecuteReader();

                while (querySdr.Read())
                {
                    trade_code = querySdr[0].ToString();
                    ems_no     = querySdr[1].ToString();
                }
                querySdr.Close();

                Dictionary <string, int> receiveOrderDic = new Dictionary <string, int>();
                //1 从收货表中查询信息
                cmd.CommandText = "select custom_materialNo, receivedNum,returnNum,cid_number from receiveOrder where _status !='return'";
                querySdr        = cmd.ExecuteReader();
                int receiveNum = 0, returnNum = 0, cidNum = 0;
                while (querySdr.Read())
                {
                    receiveNum = Int32.Parse(querySdr[1].ToString());
                    try
                    {
                        returnNum = Int32.Parse(querySdr[2].ToString());
                    }
                    catch (Exception ex)
                    {
                        returnNum = 0;
                    }
                    try
                    {
                        cidNum = Int32.Parse(querySdr[3].ToString());
                    }
                    catch (Exception ex)
                    {
                        cidNum = 0;
                    }

                    if (receiveOrderDic.ContainsKey(querySdr[0].ToString()))
                    {
                        //加上原来的数量
                        receiveOrderDic[querySdr[0].ToString()] = receiveOrderDic[querySdr[0].ToString()] + receiveNum - returnNum - cidNum;
                    }
                    else
                    {
                        receiveOrderDic.Add(querySdr[0].ToString(), receiveNum - returnNum - cidNum);
                    }
                }
                querySdr.Close();

                foreach (KeyValuePair <string, int> kvp in receiveOrderDic)
                {
                    StoreInit init1 = new StoreInit();
                    init1.ems_no = ems_no;

                    string temp = kvp.Key;
                    if (temp.Length == 10 && temp.StartsWith("000"))
                    {
                        temp = temp.Substring(3);
                    }

                    init1.cop_g_no      = temp;  //维修的板子,使用客户料号
                    init1.qty           = kvp.Value.ToString();
                    init1.unit          = "007"; //固定单位
                    init1.goods_nature  = "I";   //代码
                    init1.bom_version   = "";
                    init1.check_date    = Untils.getCustomCurrentDate();
                    init1.date_type     = "C";//代码
                    init1.whs_code      = "";
                    init1.location_code = "";
                    init1.note          = "";
                    storeInitList.Add(init1);

                    StockCheck stockcheck = new StockCheck();
                    stockcheck.material_no = temp;
                    stockcheck.num         = kvp.Value.ToString();
                    stockcheck.house       = "成品之前";
                    stockcheck.place       = "";
                    stockcheck.describe    = "维修中主板";
                    if (stockcheck.num != "0")
                    {
                        StockCheckList.Add(stockcheck);
                    }
                }

                //2 读取良品库房信息
                Dictionary <string, string> mpn_unit = new Dictionary <string, string>();
                cmd.CommandText = "select distinct mpn,declare_unit from stock_in_sheet where mpn !=''";
                querySdr        = cmd.ExecuteReader();
                while (querySdr.Read())
                {
                    if (mpn_unit.ContainsKey(querySdr[0].ToString()) == false)
                    {
                        mpn_unit.Add(querySdr[0].ToString(), querySdr[1].ToString());
                    }
                }
                querySdr.Close();

                cmd.CommandText = "select mpn, number,house,place from store_house where mpn !='' and number !='0'";
                querySdr        = cmd.ExecuteReader();
                while (querySdr.Read())
                {
                    StoreInit init1 = new StoreInit();
                    init1.ems_no = ems_no;

                    string currentDeclear = "";
                    bool   isMB           = false;
                    if (_71bomDic.ContainsKey(querySdr[0].ToString()))
                    {
                        currentDeclear = _71bomDic[querySdr[0].ToString()];
                    }
                    else if (currentDeclear == "")
                    {
                        currentDeclear = querySdr[0].ToString();//buffer主板直接用71料号存储的
                        if (currentDeclear.Length == 10 && currentDeclear.StartsWith("000"))
                        {
                            currentDeclear = currentDeclear.Substring(3);
                            isMB           = true;
                        }
                    }

                    init1.cop_g_no = currentDeclear;//因为报关原因,需要改成71料号(联想料号)TODO,包括材料与买的MB,物料对照表与71bom
                    init1.qty      = querySdr[1].ToString();
                    try
                    {
                        init1.unit = Untils.getCustomCode(mpn_unit[querySdr[0].ToString()]);
                    }
                    catch (Exception ex)
                    {
                        init1.unit = "007";
                    }
                    init1.goods_nature  = "I";//代码
                    init1.bom_version   = "";
                    init1.check_date    = Untils.getCustomCurrentDate();
                    init1.date_type     = "C";//代码
                    init1.whs_code      = "";
                    init1.location_code = "";
                    init1.note          = "";
                    storeInitList.Add(init1);

                    StockCheck stockcheck = new StockCheck();
                    stockcheck.material_no = isMB ? currentDeclear:querySdr[0].ToString();
                    stockcheck.num         = querySdr[1].ToString();
                    stockcheck.house       = querySdr[2].ToString();
                    stockcheck.place       = querySdr[3].ToString();
                    if (_71bomDescribeDic.ContainsKey(stockcheck.material_no))
                    {
                        stockcheck.describe = _71bomDescribeDic[stockcheck.material_no];
                    }
                    if (stockcheck.num != "0")
                    {
                        StockCheckList.Add(stockcheck);
                    }
                }
                querySdr.Close();

                //3 读取MB/SMT/BGA不良品信息,此处的MB是由CID过来的,所以直接用原始料号即可
                cmd.CommandText = "select mpn, number,house,place from store_house_ng where mpn !='' and number !='0'";
                querySdr        = cmd.ExecuteReader();
                while (querySdr.Read())
                {
                    StoreInit init1 = new StoreInit();
                    init1.ems_no = ems_no;

                    string currentDeclear = "";
                    bool   isMB           = false;
                    if (_71bomDic.ContainsKey(querySdr[0].ToString()))
                    {
                        currentDeclear = _71bomDic[querySdr[0].ToString()] + "-1";//海关要求料号不一样,加-1
                    }
                    else if (currentDeclear == "")
                    {
                        currentDeclear = querySdr[0].ToString();//buffer主板直接用71料号存储的
                        if (currentDeclear.Length == 10 && currentDeclear.StartsWith("000"))
                        {
                            currentDeclear = currentDeclear.Substring(3);
                            isMB           = true;
                        }
                    }

                    init1.cop_g_no = currentDeclear;//因为报关原因,需要改成71料号(联想料号)TODO
                    init1.qty      = querySdr[1].ToString();

                    try
                    {
                        init1.unit = Untils.getCustomCode(mpn_unit[querySdr[0].ToString()]);
                    }
                    catch (Exception ex)
                    {
                        init1.unit = "007";
                    }
                    init1.goods_nature  = isMB? "E" :"I";//代码
                    init1.bom_version   = "";
                    init1.check_date    = Untils.getCustomCurrentDate();
                    init1.date_type     = "C";//代码
                    init1.whs_code      = "";
                    init1.location_code = "";
                    init1.note          = "";
                    storeInitList.Add(init1);

                    StockCheck stockcheck = new StockCheck();
                    stockcheck.material_no = isMB ? currentDeclear : querySdr[0].ToString();
                    stockcheck.num         = querySdr[1].ToString();
                    stockcheck.house       = querySdr[2].ToString();
                    stockcheck.place       = querySdr[3].ToString();
                    if (_71bomDescribeDic.ContainsKey(stockcheck.material_no))
                    {
                        stockcheck.describe = _71bomDescribeDic[stockcheck.material_no];
                    }
                    else
                    {
                        stockcheck.describe = isMB ? "不良品主板" : "";
                    }
                    stockcheck.material_no += "_1";//区分良品与不良品信息
                    if (stockcheck.num != "0")
                    {
                        StockCheckList.Add(stockcheck);
                    }
                }
                querySdr.Close();

                //3-1 读取MB Buffer不良品信息,此处的MB是由良品库过来的,所以直接用原始料号71即可
                cmd.CommandText = "select mpn, number,house,place from store_house_ng_buffer_mb where mpn !='' and number !='0'";
                querySdr        = cmd.ExecuteReader();
                while (querySdr.Read())
                {
                    StoreInit init1 = new StoreInit();
                    init1.ems_no = ems_no;

                    string currentDeclear = querySdr[0].ToString().Trim();

                    init1.cop_g_no = currentDeclear;//因为报关原因,需要改成71料号(联想料号)TODO
                    init1.qty      = querySdr[1].ToString();

                    try
                    {
                        init1.unit = Untils.getCustomCode(mpn_unit[querySdr[0].ToString()]);
                    }
                    catch (Exception ex)
                    {
                        init1.unit = "007";
                    }
                    init1.goods_nature  = "E";//代码
                    init1.bom_version   = "";
                    init1.check_date    = Untils.getCustomCurrentDate();
                    init1.date_type     = "C";//代码
                    init1.whs_code      = "";
                    init1.location_code = "";
                    init1.note          = "";
                    storeInitList.Add(init1);

                    StockCheck stockcheck = new StockCheck();
                    stockcheck.material_no = currentDeclear;
                    stockcheck.num         = querySdr[1].ToString();
                    stockcheck.house       = querySdr[2].ToString();
                    stockcheck.place       = querySdr[3].ToString();
                    if (_71bomDescribeDic.ContainsKey(stockcheck.material_no))
                    {
                        stockcheck.describe = _71bomDescribeDic[stockcheck.material_no];
                    }
                    stockcheck.material_no += "_1";//区分良品与不良品信息
                    if (stockcheck.num != "0")
                    {
                        StockCheckList.Add(stockcheck);
                    }
                }
                querySdr.Close();

                //4 读取MB待维修库信息
                cmd.CommandText = "select custom_materialNo,leftNumber from wait_repair_left_house_table where leftNumber !='0'";
                querySdr        = cmd.ExecuteReader();
                while (querySdr.Read())
                {
                    StoreInit init1 = new StoreInit();
                    init1.ems_no = ems_no;

                    string temp = querySdr[0].ToString();
                    if (temp.Length == 10 && temp.StartsWith("000"))
                    {
                        temp = temp.Substring(3);
                    }

                    init1.cop_g_no      = temp;  //正常使用客户料号
                    init1.qty           = querySdr[1].ToString();
                    init1.unit          = "007"; //固定单位
                    init1.goods_nature  = "I";   //代码
                    init1.bom_version   = "";
                    init1.check_date    = Untils.getCustomCurrentDate();
                    init1.date_type     = "C";//代码
                    init1.whs_code      = "";
                    init1.location_code = "";
                    init1.note          = "";
                    storeInitList.Add(init1);

                    StockCheck stockcheck = new StockCheck();
                    stockcheck.material_no = temp;
                    stockcheck.num         = querySdr[1].ToString();
                    stockcheck.house       = "待维修库";
                    stockcheck.place       = "";
                    stockcheck.describe    = "待维修主板";
                    if (stockcheck.num != "0")
                    {
                        StockCheckList.Add(stockcheck);
                    }
                }
                querySdr.Close();

                //5 读取MB良品库信息
                cmd.CommandText = "select custom_materialNo, leftNumber from repaired_left_house_table where leftNumber !='0'";
                querySdr        = cmd.ExecuteReader();
                while (querySdr.Read())
                {
                    StoreInit init1 = new StoreInit();
                    init1.ems_no = ems_no;

                    string temp = querySdr[0].ToString();
                    if (temp.Length == 10 && temp.StartsWith("000"))
                    {
                        temp = temp.Substring(3);
                    }

                    init1.cop_g_no      = temp;  //正常使用客户料号
                    init1.qty           = querySdr[1].ToString();
                    init1.unit          = "007"; //固定单位
                    init1.goods_nature  = "E";   //代码
                    init1.bom_version   = "";
                    init1.check_date    = Untils.getCustomCurrentDate();
                    init1.date_type     = "C";//代码
                    init1.whs_code      = "";
                    init1.location_code = "";
                    init1.note          = "";
                    storeInitList.Add(init1);

                    StockCheck stockcheck = new StockCheck();
                    stockcheck.material_no = temp;
                    stockcheck.num         = querySdr[1].ToString();
                    stockcheck.house       = "良品库";
                    stockcheck.place       = "";
                    stockcheck.describe    = "维修后良品主板";
                    if (stockcheck.num != "0")
                    {
                        StockCheckList.Add(stockcheck);
                    }
                }
                querySdr.Close();

                mConn.Close();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }

            generateExcelToCheck(StockCheckList);

            openingstock.seq_no     = seq_no;
            openingstock.boxtype    = boxtype;
            openingstock.flowstateg = flowstateg;
            openingstock.trade_code = trade_code;
            openingstock.ems_no     = ems_no;
            openingstock.status     = status;

            openingstock.storeInitList = storeInitList;

            //导出xml的逻辑变成excel上传了
            if (storeInitList.Count > 0)
            {
                Untils.createOpeningStockXML(openingstock, "D:\\STORE_INIT" + seq_no + "test.xml");
                MessageBox.Show("海关期初库存信息产生成功!");
            }
            else
            {
                MessageBox.Show("没有期初库存信息!", "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
 public static ReturnType AddStockCheck(StockCheck stockCheck)
 {
     return(DataProviderClass.Instance().AddStockCheck(stockCheck));
 }
 public static ReturnType AddStockCheckAndDetails(StockCheck stockCheck, List <StockCheckDetail> CheckDetails)
 {
     return(DataProviderClass.Instance().AddStockCheckAndDetails(stockCheck, CheckDetails));
 }
 public void AddToStockChecks(StockCheck stockCheck)
 {
     base.AddObject("StockChecks", stockCheck);
 }
 public static StockCheck CreateStockCheck(int ID, global::System.DateTime stockCheckDate, byte[] rowVersion)
 {
     StockCheck stockCheck = new StockCheck();
     stockCheck.Id = ID;
     stockCheck.StockCheckDate = stockCheckDate;
     stockCheck.RowVersion = rowVersion;
     return stockCheck;
 }
Example #24
0
        protected void Page_Load(object sender, EventArgs e)
        {
            op   = RequestData.Get <string>("op");
            id   = RequestData.Get <string>("id");
            type = RequestData.Get <string>("type");
            ent  = StockCheck.Find(id);
            switch (RequestActionString)
            {
            case "WorkFlowEnd":
                ent.WorkFlowState = RequestData.Get <string>("state");
                ent.ExamineResult = RequestData.Get <string>("ApprovalState");
                ent.State         = "已结束";
                ent.DoUpdate();
                IList <StockCheckDetail> scdEnts = StockCheckDetail.FindAllByProperty("StockCheckId", id);
                foreach (StockCheckDetail scdEnt in scdEnts)
                {
                    if (scdEnt.StockCheckResult != "正常")
                    {
                        scdEnt.StockCheckState = "盘点结束";
                        scdEnt.DoUpdate();
                    }
                }
                if (ent.ExamineResult == "同意")
                {
                    foreach (StockCheckDetail scdEnt in scdEnts)
                    {
                        if (scdEnt.StockCheckResult != "正常")    //创建库存变更日志  并更改库存
                        {
                            StockLog slEnt = new StockLog();
                            slEnt.InOrOutDetailId = scdEnt.Id;
                            StockCheck scEnt = StockCheck.Find(scdEnt.StockCheckId);
                            slEnt.InOrOutBillNo = scEnt.StockCheckNo;
                            slEnt.OperateType   = "库存盘点";
                            slEnt.WarehouseId   = scEnt.WarehouseId;
                            slEnt.WarehouseName = scEnt.WarehouseName;
                            slEnt.StockQuantity = scdEnt.StockQuantity;
                            slEnt.Quantity      = scdEnt.StockCheckQuantity - scdEnt.StockQuantity;
                            slEnt.ProductId     = scdEnt.ProductId;
                            Product pEnt = Product.Find(scdEnt.ProductId);
                            slEnt.ProductName = pEnt.Name;
                            slEnt.ProductCode = pEnt.Code;
                            slEnt.ProductIsbn = pEnt.Isbn;
                            slEnt.ProductPcn  = pEnt.Pcn;
                            slEnt.CreateId    = UserInfo.UserID;
                            slEnt.CreateName  = UserInfo.Name;
                            slEnt.CreateTime  = System.DateTime.Now;
                            slEnt.DoCreate();
                            IList <StockInfo> siEnts = StockInfo.FindAllByProperties("ProductId", scdEnt.ProductId, "WarehouseId", ent.WarehouseId);
                            if (siEnts.Count > 0)
                            {
                                siEnts[0].StockQuantity = scdEnt.StockCheckQuantity;
                                siEnts[0].DoUpdate();
                            }
                        }
                    }
                }
                break;

            default:
                DoSelect();
                break;
            }
            if (op != "c" && op != "cs")
            {
                if (!String.IsNullOrEmpty(id))
                {
                    SetFormData(ent);
                }
            }
        }
Example #25
0
        /// <summary>
        /// 归档
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void bbtnSave_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            WaitDialogForm waitForm = new WaitDialogForm(Constants.OPERATE_DB_DATA);

            waitForm.Show();
            try
            {
                if (string.IsNullOrEmpty(comboBoxStockHouse.Text))
                {
                    waitForm.Close();
                    XtraMessageBox.Show("请选择仓库进行盘点!");
                    return;
                }

                if (gvProductCheck.RowCount == 0)
                {
                    waitForm.Close();
                    XtraMessageBox.Show("请选择一件商品进行盘点!");
                    return;
                }
                if (string.IsNullOrEmpty(pceOperator.Text))
                {
                    waitForm.Close();
                    XtraMessageBox.Show("请选择操作人!");
                    return;
                }
                /*盘点必须选择具体库位,否则返回*/
                if (!IsChooseLayout())
                {
                    waitForm.Close();
                    XtraMessageBox.Show("请选择具体库位!");
                    return;
                }

                /*盘点必须输入实际数量,否则返回*/
                if (!IsInputQuantity())
                {
                    waitForm.Close();
                    XtraMessageBox.Show("请输入实际数量!");
                    return;
                }

                /*开始进行盘点*/

                #region 出入库单
                ///*实例化两个StockInOut,一个用于记录报损出库,一个用于记录报溢入库*/
                //Alading.Entity.StockInOut profitInout = new Alading.Entity.StockInOut();
                //Alading.Entity.StockInOut lossInout = new Alading.Entity.StockInOut();

                //#region 初始化赋值
                //profitInout.AmountTax = 0;
                //profitInout.DiscountFee = 0;
                //profitInout.DueFee = 0;
                //profitInout.FreightCode = string.Empty;
                //profitInout.FreightCompany = string.Empty;
                //profitInout.HouseCodeIn = string.Empty;
                //profitInout.HouseCodeOut = string.Empty;
                //profitInout.HouseNameIn = string.Empty;
                //profitInout.HouseNameOut = string.Empty;
                //profitInout.IncomeTime = DateTime.Now;
                ///*GUID*/
                //profitInout.InOutCode = System.Guid.NewGuid().ToString();
                //profitInout.InOutStatus = (int)InOutStatus.AllReach;
                //profitInout.InOutTime = DateTime.Now;
                //profitInout.InOutType = (int)InOutType.ProfitIn;
                //profitInout.IsSettled = true;
                ///*操作人,暂时为空*/
                //profitInout.OperatorCode = string.Empty;
                //profitInout.OperatorName = string.Empty;

                //profitInout.PayTerm = DateTime.Now;
                //profitInout.PayThisTime = 0;
                //profitInout.PayType = (int)PayType.OTHER;
                //profitInout.SearchText = string.Empty;
                //profitInout.TradeOrderCode = string.Empty;
                //profitInout.TransportCode = string.Empty;

                //lossInout.AmountTax = 0;
                //lossInout.DiscountFee = 0;
                //lossInout.DueFee = 0;
                //lossInout.FreightCode = string.Empty;
                //lossInout.FreightCompany = string.Empty;
                //lossInout.HouseCodeIn = string.Empty;
                //lossInout.HouseCodeOut = string.Empty;
                //lossInout.HouseNameIn = string.Empty;
                //lossInout.HouseNameOut = string.Empty;
                //lossInout.IncomeTime = DateTime.Now;
                ///*GUID*/
                //lossInout.InOutCode = System.Guid.NewGuid().ToString();
                //lossInout.InOutStatus = (int)InOutStatus.AllReach;
                //lossInout.InOutTime = DateTime.Now;
                //lossInout.InOutType = (int)InOutType.ProfitIn;
                //lossInout.IsSettled = true;
                ///*操作人,暂时为空*/
                //lossInout.OperatorCode = string.Empty;
                //lossInout.OperatorName = string.Empty;

                //lossInout.PayTerm = DateTime.Now;
                //lossInout.PayThisTime = 0;
                //lossInout.PayType = (int)PayType.OTHER;
                //lossInout.SearchText = string.Empty;
                //lossInout.TradeOrderCode = string.Empty;
                //lossInout.TransportCode = string.Empty;
                //#endregion
                #endregion

                Hashtable table     = comboBoxStockHouse.Tag as Hashtable;
                string    houseCode = table[comboBoxStockHouse.SelectedIndex].ToString();
                int       rowCount  = gvProductCheck.RowCount;
                /*盘点详情列表*/
                //List<StockCheckDetail> stockCheckDetailList = new List<StockCheckDetail>();

                #region 盘点单

                StockCheck stockCheck = new StockCheck();
                stockCheck.Created = DateTime.Now;
                /*操作人*/
                stockCheck.OperatorCode = pceOperator.Tag != null?pceOperator.Tag.ToString() : string.Empty;

                /*盘点单号*/
                //string year = DateTime.Now.Year.ToString();
                //string month = DateTime.Now.Month.ToString();
                //string day = DateTime.Now.Day.ToString();
                //string hour = DateTime.Now.Hour.ToString();
                //string minute = DateTime.Now.Minute.ToString();
                //string second = DateTime.Now.Second.ToString();
                //stockCheck.StockCheckCode = "PDD-"+year+month+day+"-"+hour+minute+second;
                stockCheck.StockCheckCode = !string.IsNullOrEmpty(textEditCheckCode.Text) ? textEditCheckCode.Text.Trim() : System.Guid.NewGuid().ToString();
                stockCheck.StockHouseCode = houseCode;
                #endregion

                if (StockDetailService.AddStockCheck(stockCheck) == ReturnType.Success)
                {
                    for (int i = 0; i < rowCount; i++)
                    {
                        DataRow row          = gvProductCheck.GetDataRow(i);
                        string  profitType   = row[gcProfitType.FieldName].ToString();
                        string  skuOuterId   = row[gcSkuOuterID.FieldName].ToString();
                        int     factQuantity = int.Parse(row[gcQuantity.FieldName].ToString());
                        int     skuQuantity  = int.Parse(row[gcSkuQuantity.FieldName].ToString());
                        string  layoutCode   = row[gcLayoutCode.FieldName].ToString();
                        string  layoutName   = row[gcLayoutName.FieldName].ToString();

                        #region 盘点入库Detail
                        StockDetail stockDetail = new StockDetail();
                        stockDetail.DetailRemark   = string.Empty;
                        stockDetail.DetailType     = (int)DetailType.CheckIn;
                        stockDetail.DurabilityDate = DateTime.Now;
                        stockDetail.HouseName      = comboBoxStockHouse.Text;
                        stockDetail.InOutCode      = string.Empty;
                        stockDetail.LayoutName     = layoutName;
                        /*价格问题??????*/
                        stockDetail.Price             = row[gcPrice.FieldName] != null && row[gcPrice.FieldName].ToString() != string.Empty ? float.Parse(row[gcPrice.FieldName].ToString()) : 0;
                        stockDetail.ProductSkuOuterId = skuOuterId;
                        stockDetail.Quantity          = factQuantity;
                        /*搜索字段*/
                        stockDetail.SearchText      = string.Empty;
                        stockDetail.StockDetailCode = System.Guid.NewGuid().ToString();
                        stockDetail.StockHouseCode  = houseCode;
                        stockDetail.StockLayOutCode = layoutCode;
                        stockDetail.Tax             = string.Empty;
                        stockDetail.TotalFee        = stockDetail.Price * stockDetail.Quantity;
                        #endregion

                        #region 盘点详情

                        StockCheckDetail stockCheckDetail = new StockCheckDetail();
                        /*报溢/报损数量*/
                        stockCheckDetail.CheckQuantity = factQuantity - skuQuantity;
                        if (stockCheckDetail.CheckQuantity < 0)
                        {
                            stockCheckDetail.CheckQuantity = -stockCheckDetail.CheckQuantity;
                        }

                        stockCheckDetail.LayoutCode = layoutCode;
                        /*实际数量*/
                        stockCheckDetail.Quantity = factQuantity;
                        /*搜索字段*/
                        stockCheckDetail.SearchText = string.Empty;
                        stockCheckDetail.SkuOuterID = skuOuterId;
                        /*账面数量*/
                        stockCheckDetail.SkuQuantity    = skuQuantity;
                        stockCheckDetail.StockCheckCode = stockCheck.StockCheckCode;
                        #endregion

                        /*将所有该仓库该库位的商品出入库详情取出,放入历史表*/
                        List <StockDetail> hisStockDetailList = StockDetailService.GetStockDetail(c => c.ProductSkuOuterId == skuOuterId && c.StockHouseCode == houseCode && c.StockLayOutCode == layoutCode);

                        if (profitType == "1")
                        {
                            /*报溢处理*/
                            StockDetail profitDetail = new StockDetail();
                            profitDetail.DetailRemark      = "报溢入库";
                            profitDetail.DetailType        = (int)DetailType.ProfitIn;
                            profitDetail.DurabilityDate    = stockDetail.DurabilityDate;
                            profitDetail.HouseName         = stockDetail.HouseName;
                            profitDetail.InOutCode         = string.Empty;
                            profitDetail.LayoutName        = stockDetail.LayoutName;
                            profitDetail.Price             = stockDetail.Price;
                            profitDetail.ProductSkuOuterId = stockDetail.ProductSkuOuterId;
                            /*报溢入库数量=实际数量-账面数量*/
                            profitDetail.Quantity = factQuantity - skuQuantity;
                            /*搜索字段*/
                            profitDetail.SearchText      = string.Empty;
                            profitDetail.StockDetailCode = System.Guid.NewGuid().ToString();
                            profitDetail.StockHouseCode  = houseCode;
                            profitDetail.StockLayOutCode = layoutCode;
                            profitDetail.Tax             = string.Empty;
                            /*总花费*/
                            profitDetail.TotalFee = profitDetail.Quantity * profitDetail.Price;
                            hisStockDetailList.Add(profitDetail);

                            /*盘点详情的类型为报溢*/
                            stockCheckDetail.ProfitType = (int)ProfitType.PROFIT;
                        }
                        else if (profitType == "2")
                        {
                            /*报损处理*/
                            StockDetail LossDetail = new StockDetail();
                            LossDetail.DetailRemark      = "报损入库";
                            LossDetail.DetailType        = (int)DetailType.LossOut;
                            LossDetail.DurabilityDate    = stockDetail.DurabilityDate;
                            LossDetail.HouseName         = stockDetail.HouseName;
                            LossDetail.InOutCode         = string.Empty;
                            LossDetail.LayoutName        = stockDetail.LayoutName;
                            LossDetail.Price             = stockDetail.Price;
                            LossDetail.ProductSkuOuterId = stockDetail.ProductSkuOuterId;
                            /*报损出库数量=实际数量-账面数量*/
                            LossDetail.Quantity = skuQuantity - factQuantity;
                            /*搜索字段*/
                            LossDetail.SearchText      = string.Empty;
                            LossDetail.StockDetailCode = System.Guid.NewGuid().ToString();
                            LossDetail.StockHouseCode  = houseCode;
                            LossDetail.StockLayOutCode = layoutCode;
                            LossDetail.Tax             = string.Empty;
                            /*总花费*/
                            LossDetail.TotalFee = LossDetail.Quantity * LossDetail.Price;
                            hisStockDetailList.Add(LossDetail);

                            /*盘点详情的类型为报损*/
                            stockCheckDetail.ProfitType = (int)ProfitType.LOSS;
                        }
                        else
                        {
                            /*正常处理*/
                            stockCheckDetail.ProfitType = (int)ProfitType.NORMAL;
                        }
                        /*盘点详情列表*/
                        //stockCheckDetailList.Add();
                        /*盘点单需要的参数:1、类型(报溢/报损)2、报溢或报损数量 3、历史出入库详情 4、盘点入库详情 5、盘点单列表*/
                        StockDetailService.Check(factQuantity - skuQuantity, hisStockDetailList, stockDetail, stockCheckDetail);
                    }
                }
                else
                {
                    /**/
                }
                gvProductCheck.BestFitColumns();
                gridViewDetail.BestFitColumns();
                waitForm.Close();
            }
            catch (Exception ex)
            {
                waitForm.Close();
                XtraMessageBox.Show(ex.ToString(), Constants.SYSTEM_PROMPT, MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
        public ReturnType AddStockCheckAndDetails(StockCheck stockCheck, List <StockCheckDetail> CheckDetails)
        {
            try
            {
                using (AladingEntities alading = new AladingEntities(AppSettings.GetConnectionString()))
                {
                    alading.AddToStockCheck(stockCheck);
                    foreach (StockCheckDetail detail in CheckDetails)
                    {
                        alading.AddToStockCheckDetail(detail);

                        #region StockInOut
                        Alading.Entity.StockInOut stockInOut = new Alading.Entity.StockInOut();
                        stockInOut.AmountTax      = 0;
                        stockInOut.DiscountFee    = 0;
                        stockInOut.DueFee         = 0;
                        stockInOut.FreightCode    = string.Empty;
                        stockInOut.FreightCompany = string.Empty;
                        stockInOut.InOutCode      = Guid.NewGuid().ToString();
                        stockInOut.InOutTime      = DateTime.Now;
                        if (detail.ProfitType == (int)ProfitType.PROFIT)
                        {
                            stockInOut.InOutType = (int)InOutType.ProfitIn;
                        }
                        else
                        {
                            stockInOut.InOutType = (int)InOutType.LossOut;
                        }
                        stockInOut.TradeOrderCode = string.Empty;

                        stockInOut.OperatorCode = stockCheck.OperatorCode;
                        stockInOut.OperatorName = string.Empty;
                        stockInOut.PayType      = (int)PayType.CASH;

                        stockInOut.IsSettled   = true;
                        stockInOut.PayTerm     = 0;
                        stockInOut.IncomeTime  = DateTime.MinValue;
                        stockInOut.PayThisTime = 0;
                        #endregion

                        #region StockDetail
                        StockDetail stockDetailOut = new StockDetail();
                        stockDetailOut.ProductSkuOuterId = detail.SkuOuterID;
                        stockDetailOut.DetailRemark      = string.Empty;
                        stockDetailOut.DetailType        = (int)DetailType.AllocateOut;
                        stockDetailOut.DurabilityDate    = DateTime.Now;
                        stockDetailOut.InOutCode         = stockInOut.InOutCode;
                        stockDetailOut.Price             = 0;
                        stockDetailOut.Quantity          = detail.CheckQuantity;
                        stockDetailOut.StockDetailCode   = Guid.NewGuid().ToString();
                        stockDetailOut.StockHouseCode    = stockCheck.StockHouseCode;
                        stockDetailOut.StockLayOutCode   = detail.LayoutCode;
                        stockDetailOut.Tax      = string.Empty;
                        stockDetailOut.TotalFee = 0;
                        #endregion

                        StockProduct product = alading.StockProduct.FirstOrDefault(i => i.SkuOuterID == detail.SkuOuterID);
                        if (product != null)
                        {
                            product.SkuQuantity = detail.Quantity;//归档
                        }
                        alading.AddToStockInOut(stockInOut);
                        alading.AddToStockDetail(stockDetailOut);
                    }

                    alading.SaveChanges();
                    return(ReturnType.Success);
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }