private void simpleButton3_Click(object sender, EventArgs e)
        {
            test();
            fid_tb.Clear();
            int[] rownumber = this.gridView采购订单列表.GetSelectedRows();//获取选中行号;
            if (rownumber.Length > 0)
            {
                foreach (var sub11 in rownumber)
                {
                    if (gridView采购订单列表.FocusedRowHandle > -1)
                    {
                        var list         = gridView采购订单列表.DataSource as V_ICPOBILLMODEL[];
                        var icprbilldata = list[sub11];
                        if (icprbilldata.FSTATUS != 3)
                        {
                            // MsgHelper.ShowInformation("只有审核过的订单才可同步厂家!");
                            continue;
                        }
                        if (icprbilldata.FSYNCSTATUS != 0)
                        {
                            //MsgHelper.ShowInformation("该订单不可同步到厂家!");
                            continue;
                        }
                        string fid       = icprbilldata.FID;
                        var    listEntry = _service.GetOrderEntryList(fid, null);
                        List <ICPOBILLENTRYMODEL> listICPO = new List <ICPOBILLENTRYMODEL>();



                        foreach (var sub in listEntry)
                        {
                            if (listICPO.Any(x => x.FITEMID == sub.FITEMID))
                            {
                                ICPOBILLENTRYMODEL theOne = listICPO.First(x => x.FITEMID == sub.FITEMID);
                                theOne.FSRCQTY += (int)sub.FSRCQTY;
                            }
                            else
                            {
                                ICPOBILLENTRYMODEL t = new ICPOBILLENTRYMODEL();
                                t.FentryTotal = listEntry.Count();
                                t.FENTRYID    = sub.FENTRYID;
                                t.FITEMID     = sub.FITEMID;
                                t.Flevel      = sub.Flevel;
                                t.FCOLORNO    = sub.FCOLORNO;
                                t.FcontractNO = sub.FcontractNO;
                                t.Funit       = sub.Funit;
                                t.FAUDQTY     = sub.FAUDQTY;
                                t.FPRICE      = sub.FPRICE;
                                t.Famount     = sub.Famount;
                                t.FREMARK     = sub.FREMARK;
                                t.FSRCQTY     = (int)sub.FSRCQTY;
                                listICPO.Add(t);
                            }
                        }

                        ICPOBILLMODEL tempBillModel = icprbilldata;


                        Regex  regInt = new Regex("(\\d+)");
                        string strHM  = "";
                        string strMC  = "";
                        string comid  = "";

                        V_CLIENTACCOUNTModel singleDic = _service.GetClientAccountSingle(icprbilldata.FCLIENTID);
                        if (singleDic == null)
                        {
                            MsgHelper.ShowInformation("客户号码为空,不可同步!");
                            return;
                        }
                        else
                        {
                            try
                            {
                                strHM = regInt.Match(singleDic.FACCOUNT).Groups[1].Value;
                                strMC = singleDic.FNAME;
                                if (singleDic.FACCOUNT.Contains("FDK"))
                                {
                                    comid = "10";
                                }
                                else if (singleDic.FACCOUNT.Contains("MN"))
                                {
                                    comid = "2";
                                }
                                else if (singleDic.FACCOUNT.Contains("GW"))
                                {
                                    comid = "3";
                                }
                            }
                            catch
                            {
                            }
                        }
                        if (string.IsNullOrEmpty(strHM))
                        {
                            MsgHelper.ShowInformation("客户号码为空,不可同步!");
                            return;
                        }



                        MApiModel.api3.Rootobject api3 = new MApiModel.api3.Rootobject();
                        api3.action = "setMN_cp_24";
                        api3.token  = "";
                        api3.comid  = comid;
                        List <MApiModel.api3.Datum> listSubItems = new List <MApiModel.api3.Datum>();



                        foreach (var sub in listICPO)
                        {
                            ProductViewModel pro = _service.getProductView(sub.FITEMID);



                            MApiModel.api3.Datum subItem = new MApiModel.api3.Datum();
                            subItem.sourceno = tempBillModel.FBILLNO;
                            subItem.rq       = tempBillModel.FBILLDATE.Year + "/" + tempBillModel.FBILLDATE.Month + "/" + tempBillModel.FBILLDATE.Day;
                            // subItem.comid = "101";
                            subItem.khhm = strHM;
                            subItem.khmc = strMC;
                            subItem.pjhm = tempBillModel.FprojectNO;
                            subItem.zdr  = "300384";
                            /////////////////////////////////////////////////////
                            string[] strArr = pro.FSRCCODE.Split(new string[] { "||" }, StringSplitOptions.RemoveEmptyEntries);



                            //产品品种
                            subItem.cppz = (strArr.Length == 3 ? strArr[0] : "");
                            //产品规格
                            subItem.cpgg = (strArr.Length == 3 ? strArr[2] : "");
                            //产品型号
                            subItem.cpxh = (strArr.Length == 3 ? strArr[1] : "");

                            subItem.cpdj = sub.Flevel == null ? "1" : sub.Flevel;
                            subItem.cpsh = string.IsNullOrEmpty(sub.FCOLORNO) ? "" : sub.FCOLORNO;

                            //产品仓号
                            subItem.cpcm = string.IsNullOrEmpty(sub.FstockNO) ? "" : sub.FstockNO;
                            // subItem.package = sub.FcontractNO
                            subItem.dw = string.IsNullOrEmpty(pro.FSRCUNIT) ? "" : pro.FSRCUNIT;
                            //包装片数
                            subItem.ks    = (int)decimal.Parse(pro.FPKGFORMAT);
                            subItem.sl    = (int)sub.FSRCQTY;
                            subItem.dj    = sub.FPRICE;
                            subItem.je    = subItem.sl * subItem.dj;//(int)sub.Famount;
                            subItem.khhm1 = sub.FENTRYID.ToStr();
                            subItem.bz    = sub.FREMARK;
                            listSubItems.Add(subItem);
                        }

                        api3.data = listSubItems.ToArray();
                        //api3.data = listSubItems;

                        optType = "3";
                        string fid1 = tempBillModel.FID;
                        if (!fid_tb.ContainsKey(fid1))
                        {
                            fid_tb.Add(fid1, api3);
                        }
                    }
                    else
                    {
                    }
                }

                if (fid_tb.Count > 0)
                {
                    optType = "3";


                    if (!backgroundWorker2.IsBusy)
                    {
                        seButton(false);
                        backgroundWorker2.RunWorkerAsync();
                    }
                }
                else
                {
                    MsgHelper.ShowInformation("请选择你要确认的数据!");
                }
            }
        }
 public int Update_FSYNStatus(ICPOBILLMODEL billMode, int iStatus)
 {
     return(ICPOBILLDAL.Instance.UpdateWhatWhere(new { FSYNCSTATUS = iStatus }, new { FID = billMode.FID }));
 }
Esempio n. 3
0
        private void simpleButton3_Click(object sender, EventArgs e)
        {
            var list = gridControl采购订单列表.DataSource as List <V_ICPOBILLENTRYMODEL>;

            if (list.Count == 0)
            {
                System.Windows.Forms.MessageBox.Show("明细记录数不可为空!");
                return;
            }

            string        brand  = "";
            TB_BrandModel bmodel = comBrand.SelectedItem as TB_BrandModel;

            if (bmodel != null)
            {
                brand = bmodel.FID;
                IniHelper.WriteString(Global.IniUrl, "CONFIG", "FBRANDID", bmodel.FID);
            }
            else
            {
                System.Windows.Forms.MessageBox.Show("品牌不可为空!");
                return;
            }


            if (txt厂家账户.Tag == null)
            {
                System.Windows.Forms.MessageBox.Show("厂家账户不可为空!");
                return;
            }


            if (model == default(V_ICPOBILLMODEL) || model == null)
            {
                ICPOBILLMODEL tBill = new ICPOBILLMODEL();
                tBill.FTRANSTYPE  = "0";
                tBill.FID         = "";
                tBill.FBRANDID    = model.FID;
                tBill.FCLIENTID   = txt厂家账户.Tag.ToStr();
                tBill.FDATE       = dateDatetime.DateTime;
                tBill.FBILLNO     = _service.GetNewBillNo("PO");
                tBill.FBILLERNAME = txtCreater.Text;
                tBill.FBILLER     = txtCreater.Tag.ToStr();
                tBill.FSTATE      = 1;


                int iTemp = 1;

                List <ICPOBILLENTRYMODEL> listSub = new List <ICPOBILLENTRYMODEL>();
                foreach (var sub in list)
                {
                    sub.FENTRYID = iTemp;

                    ICPOBILLENTRYMODEL sub0 = new ICPOBILLENTRYMODEL();
                    sub0.FADVQTY     = sub.FADVQTY;
                    sub0.FBATCHNO    = sub.FBATCHNO;
                    sub0.FCOLORNO    = sub.FCOLORNO;
                    sub0.FENTRYID    = sub.FENTRYID;
                    sub0.FICPOBILLID = sub.FICPOBILLID;
                    sub0.FID         = sub.FID;
                    sub0.FNEEDDATE   = sub.FNEEDDATE;
                    sub0.FPLANID     = sub.FPLANID;
                    sub0.FPRICE      = sub.FPRICE;
                    sub0.FREMARK     = sub.FREMARK;
                    sub0.FSRCCOST    = sub.FSRCCOST;
                    sub0.FSRCQTY     = sub.FSRCQTY;
                    sub0.FSTATE      = sub.FSTATE;
                    sub0.FSTATUS     = sub.FSTATUS;
                    listSub.Add(sub0);
                }

                string sResult = _service.SaveICPOBILL(tBill, listSub.ToArray());

                System.Windows.Forms.MessageBox.Show(sResult);
                if (this.SaveAfter != null)
                {
                    SaveAfter(null, null);
                }
                this.Close();
            }
            else
            {
                ICPOBILLMODEL tModel = _service.GetSingleOrder(model.FID);
                tModel.FBRANDID   = bmodel.FID;
                tModel.FCLIENTID  = txt厂家账户.Tag.ToStr();
                tModel.FDATE      = dateDatetime.DateTime;
                tModel.FTELEPHONE = txtPhone.Text;
                tModel.FREMARK    = txtRemarks.Text;
                //tModel.FSTATUS = 3;
                int iTemp = 1;
                List <ICPOBILLENTRYMODEL> listSub = new List <ICPOBILLENTRYMODEL>();
                foreach (var sub in list)
                {
                    sub.FENTRYID = iTemp;
                    ICPOBILLENTRYMODEL sub0 = new ICPOBILLENTRYMODEL();
                    sub0.FADVQTY     = sub.FADVQTY;
                    sub0.FBATCHNO    = sub.FBATCHNO;
                    sub0.FCOLORNO    = sub.FCOLORNO;
                    sub0.FENTRYID    = sub.FENTRYID;
                    sub0.FICPOBILLID = sub.FICPOBILLID;
                    sub0.FNEEDDATE   = sub.FNEEDDATE;
                    sub0.FPLANID     = sub.FPLANID;
                    sub0.FPRICE      = sub.FPRICE;
                    sub0.FREMARK     = sub.FREMARK;
                    sub0.FSRCCOST    = sub.FSRCCOST;
                    sub0.FSRCQTY     = sub.FSRCQTY;
                    //sub0.FSTATUS = 3;
                    listSub.Add(sub0);
                }



                string sResult = _service.SaveICPOBILL(tModel, listSub.ToArray());

                System.Windows.Forms.MessageBox.Show(sResult);
                if (this.SaveAfter != null)
                {
                    SaveAfter(null, null);
                }
                this.Close();
            }
        }
Esempio n. 4
0
        public string Save(ICPOBILLMODEL ICPOBILL, IEnumerable <ICPOBILLENTRYMODEL> ICPOBILLENTRYList)
        {
            string FID = null;

            #region 执行前检测
            if (!ICPOBILL.FID.IsGuid())
            {
                ICPOBILLMODEL temp = ICPOBILLDAL.Instance.GetWhere(new { FBILLNO = ICPOBILL.FBILLNO }).FirstOrDefault();

                if (temp != null && temp.FID != ICPOBILL.FID)
                {
                    return("采购订单编号重复!");
                }
            }

            //foreach (var item in ICPOBILLENTRYList.GroupBy(i => i.FITEMID + i.FENTRYID))
            //{
            //    if (item.Count() > 1)
            //    {
            //        return "采购订单明细商品信息重复!";
            //    }
            //}

            //foreach (var item in ICPOPOLICYList.GroupBy(i => i.FITEMID + i.FSRCENTRYID))
            //{
            //    if (item.Count() > 1)
            //    {
            //        return "采购订单价格政策商品信息重复!";
            //    }
            //}

            #endregion

            #region 保存主表

            if (!ICPOBILL.FID.IsGuid())
            {
                ICPOBILL.FSTATUS     = 1;
                ICPOBILL.FSTATE      = 1;
                ICPOBILL.FBILLER     = SysVisitor.Instance.UserId;
                ICPOBILL.FBILLERNAME = SysVisitor.Instance.UserName;
                ICPOBILL.FBILLDATE   = DateTime.Now;

                FID = ICPOBILLDAL.Instance.Insert(ICPOBILL);

                if (!FID.IsGuid())
                {
                    return("保存采购订单失败!");
                }
            }
            else
            {
                FID = ICPOBILL.FID;

                var model = ICPOBILLDAL.Instance.Get(FID);
                model.FBRANDID   = ICPOBILL.FBRANDID;
                model.FCLIENTID  = ICPOBILL.FCLIENTID;
                model.FREMARK    = ICPOBILL.FREMARK;
                model.FDATE      = ICPOBILL.FDATE;
                model.FTELEPHONE = ICPOBILL.FTELEPHONE;
                ICPOBILLDAL.Instance.Update(model);
                //if (ICPOBILLDAL.Instance.UpdateWhatWhere(new
                //{
                //    FBILLER = SysVisitor.Instance.UserId,
                //    FBILLERNAME = SysVisitor.Instance.UserName,
                //    //FSRCPRID=ICPOBILL.FSRCPRID,
                //    FTRANSTYPE = ICPOBILL.FTRANSTYPE
                //}, new
                //{
                //    FID = FID
                //}) <= 0)
                //{
                //    return "保存采购订单失败";
                //}
            }

            #endregion

            #region 保存子表

            //删除明细
            ICPOBILLENTRYBLL.Instance.DeleteByICPOBILLID(FID);

            //删除价格政策
            //ICPOPOLICYBLL.Instance.DeleteByICPOBILLID(FID);

            //保存明细
            foreach (var item in ICPOBILLENTRYList)
            {
                item.FICPOBILLID = FID;
                ICPOBILLENTRYDAL.Instance.Insert(item);

                //更新请购计划明细里面的采购订单编号
                ICPRBILLENTRYDAL.Instance.UpdateWhatWhere(new { FICPOBILLNO = ICPOBILL.FBILLNO }, new { FID = item.FPLANID });
            }

            ////保存价格政策
            //foreach (var item in ICPOPOLICYList)
            //{
            //    ICPOPOLICYBLL.Instance.Add(item, FID);
            //}

            #endregion

            return(null);
        }
Esempio n. 5
0
        public string SaveClient(ICPOBILLMODEL ICPOBILL, IEnumerable <ICPOBILLENTRYMODEL> ICPOBILLENTRYList)
        {
            string FID = null;

            #region 执行前检测
            if (!ICPOBILL.FID.IsGuid())
            {
                ICPOBILLMODEL temp = ICPOBILLDAL.Instance.GetWhere(new { FBILLNO = ICPOBILL.FBILLNO }).FirstOrDefault();

                if (temp != null && temp.FID != ICPOBILL.FID)
                {
                    return("采购订单编号重复!");
                }
            }

            //foreach (var item in ICPOBILLENTRYList.GroupBy(i => i.FITEMID + i.FENTRYID))
            //{
            //    if (item.Count() > 1)
            //    {
            //        return "采购订单明细商品信息重复!";
            //    }
            //}

            //foreach (var item in ICPOPOLICYList.GroupBy(i => i.FITEMID + i.FSRCENTRYID))
            //{
            //    if (item.Count() > 1)
            //    {
            //        return "采购订单价格政策商品信息重复!";
            //    }
            //}

            #endregion

            #region 保存主表

            if (!ICPOBILL.FID.IsGuid())
            {
                ICPOBILL.FSTATUS      = 1;
                ICPOBILL.FSTATE       = 1;
                ICPOBILL.FBILLER      = ICPOBILL.FBILLER;
                ICPOBILL.FBILLERNAME  = ICPOBILL.FBILLER;
                ICPOBILL.FBILLDATE    = DateTime.Now;
                ICPOBILL.Fpricepolicy = ICPOBILL.Fpricepolicy;
                ICPOBILL.FPOtype      = ICPOBILL.FPOtype;
                ICPOBILL.Fnote        = ICPOBILL.Fnote;
                FID = ICPOBILLDAL.Instance.Insert(ICPOBILL);

                if (!FID.IsGuid())
                {
                    return("保存采购订单失败!" + FID);
                }
            }
            else
            {
                FID = ICPOBILL.FID;

                var model = ICPOBILLDAL.Instance.Get(FID);
                model.FCLIENTID    = ICPOBILL.FCLIENTID;
                model.FREMARK      = ICPOBILL.FREMARK;
                model.FDATE        = ICPOBILL.FDATE;
                model.FTELEPHONE   = ICPOBILL.FTELEPHONE;
                model.Fpricepolicy = ICPOBILL.Fpricepolicy;
                model.FPOtype      = ICPOBILL.FPOtype;
                model.Fnote        = ICPOBILL.Fnote;
                int iResult = ICPOBILLDAL.Instance.Update(model);

                // return model.Fpricepolicy + "-"+ FID;
            }

            #endregion

            #region 保存子表

            LogHelper.WriteLog("ICPOBILLENTRYMODEL.FID=" + FID);
            List <ICPOBILLENTRYMODEL> tList = ICPOBILLENTRYDAL.Instance.GetWhere(new { FICPOBILLID = FID }).ToList();
            if (tList.Count > 0)
            {
                foreach (var sub in tList)
                {
                    if (!string.IsNullOrEmpty(sub.ICPRBILLENTRYIDS))
                    {
                        string[] str = sub.ICPRBILLENTRYIDS.Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries);

                        foreach (var subS in str)
                        {
                            ICPRBILLENTRYDAL.Instance.UpdateWhatWhere(new { FICPOBILLNO = "", ICPOBILLENTRYID = "" }, new { FID = subS });
                        }
                    }
                }
            }


            //删除明细
            ICPOBILLENTRYBLL.Instance.DeleteByICPOBILLID(FID);

            //删除价格政策
            //ICPOPOLICYBLL.Instance.DeleteByICPOBILLID(FID);

            //保存明细
            foreach (var item in ICPOBILLENTRYList)
            {
                item.FICPOBILLID = FID;
                string fEntryID = ICPOBILLENTRYDAL.Instance.Insert(item);

                LogHelper.WriteLog("FICPOBILLID=" + FID + " fEntryID=" + fEntryID);

                if (fEntryID.IsGuid())
                {
                    LogHelper.WriteLog("item.ICPRBILLENTRYIDS=" + item.ICPRBILLENTRYIDS);
                    if (!string.IsNullOrEmpty(item.ICPRBILLENTRYIDS))
                    {
                        string[] str = item.ICPRBILLENTRYIDS.Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries);

                        foreach (var subS in str)
                        {
                            LogHelper.WriteLog("ICPRBILLENTRYID=" + subS + " ICPOBILLENRYID=" + fEntryID);
                            ICPRBILLENTRYDAL.Instance.UpdateWhatWhere(new { FICPOBILLNO = ICPOBILL.FBILLNO, ICPOBILLENTRYID = fEntryID }, new { FID = subS });
                        }
                    }
                }
            }

            #endregion

            return(null);
        }
Esempio n. 6
0
        public string SaveClient(ICPOBILLMODEL ICPOBILL, IEnumerable <ICPOBILLENTRYMODEL> ICPOBILLENTRYList)
        {
            OracleDBHelper helper = new OracleDBHelper();
            var            conn   = helper.GetNewConnection();

            conn.Open();
            var tran = conn.BeginTransaction();

            try
            {
                string FID = null;

                #region 执行前检测
                if (!ICPOBILL.FID.IsGuid())
                {
                    ICPOBILLMODEL temp = ICPOBILLDAL.Instance.GetWhere(new { FBILLNO = ICPOBILL.FBILLNO }).FirstOrDefault();

                    if (temp != null && temp.FID != ICPOBILL.FID)
                    {
                        return("采购订单编号重复!");
                    }
                }

                #endregion

                #region 保存主表

                if (!ICPOBILL.FID.IsGuid())
                {
                    FID = Guid.NewGuid().ToString();
                    ICPOBILL.FSTATUS     = 1;
                    ICPOBILL.FSTATE      = 1;
                    ICPOBILL.FBILLERNAME = ICPOBILL.FBILLER;
                    ICPOBILL.FBILLDATE   = DateTime.Now;
                    ICPOBILL.FID         = FID;
                    ICPOBILL.FSYNCSTATUS = 0;
                    helper.InsertWithTransation(ICPOBILL, tran);
                }
                else
                {
                    FID = ICPOBILL.FID;
                    //var model = ICPOBILLDAL.Instance.Get(FID);
                    //model.FCLIENTID = ICPOBILL.FCLIENTID;
                    //model.FREMARK = ICPOBILL.FREMARK;
                    //model.FDATE = ICPOBILL.FDATE;
                    //model.FTELEPHONE = ICPOBILL.FTELEPHONE;
                    //model.Fpricepolicy = ICPOBILL.Fpricepolicy;
                    //model.FPOtype = ICPOBILL.FPOtype;
                    //model.Fnote = ICPOBILL.Fnote;
                    //model.FPREMISEID = ICPOBILL.FPREMISEID;

                    helper.UpdateWithTransation(ICPOBILL, tran);
                }

                #endregion

                #region 保存子表

                //删除明细
                //ICPOBILLENTRYBLL.Instance.DeleteByICPOBILLID(FID);
                helper.DeleteWithTran <ICPOBILLENTRYMODEL>($"AND  FICPOBILLID='{FID}'", tran);

                //保存明细
                foreach (var item in ICPOBILLENTRYList)
                {
                    item.FICPOBILLID = FID;
                    item.FID         = Guid.NewGuid().ToString();

                    helper.InsertWithTransation(item, tran);
                }

                #endregion
                tran.Commit();
                conn.Dispose();
                return(null);
            }
            catch (Exception e)
            {
                tran.Rollback();
                LogHelper.Info("e.Message=" + e.Message);
                throw;
            }
        }