Ejemplo n.º 1
0
        public bool Remote_InsertICPOEntry(ICPOBILLMODEL billModel, ICPOBILLENTRYMODEL entryModel)
        {
            MApiAccess.AccessApi Mapi = new MApiAccess.AccessApi();
            if (string.IsNullOrEmpty(Global.g_token.tokenInfo.endDate) || DateTime.Parse(Global.g_token.tokenInfo.endDate) < DateTime.Now)
            {
                MApiModel.api1.Rootobject tempToken = new MApiModel.api1.Rootobject();
                tempToken.comid   = 101;
                tempToken.action  = "getToken";
                tempToken.khhm    = "300384";
                tempToken.openkey = "10011630";
                Global.g_token    = Mapi.AccessApi1(tempToken);
            }

            MApiModel.api3.Rootobject api3 = new MApiModel.api3.Rootobject();
            api3.action = "setMN_cp_24";
            api3.token  = Global.g_token.token;

            List <MApiModel.api3.Datum> listSubItems = new List <MApiModel.api3.Datum>();


            MApiModel.api3.Datum subItem = new MApiModel.api3.Datum();
            subItem.sourceno = billModel.FBILLNO;
            subItem.rq       = billModel.FDATESTR;
            subItem.comid    = "101";
            //subItem.khhm = billModel.Fcompany;
            //subItem.khmc=
            //subItem.pjhm = "";
            subItem.zdr = billModel.FBILLER;
            //产品品种
            //subItem.cppz=billModel
            //产品规格
            //subItem.cpgg = "";
            //产品型号
            subItem.cpxh = "";
            subItem.cpdj = entryModel.Flevel;
            subItem.cpsh = entryModel.FCOLORNO;
            //产品仓号
            subItem.cpcm    = entryModel.FstockNO;
            subItem.package = entryModel.FcontractNO;
            subItem.dw      = entryModel.Funit;
            //包装片数
            //subItem.ks=entryModel.
            subItem.sl = int.Parse(entryModel.FSRCQTY.ToString());
            subItem.je = int.Parse(entryModel.Famount.ToString());

            listSubItems.Add(subItem);

            api3.data = listSubItems.ToArray();

            MApiModel.recApi3.Rootobject recapi3 = Mapi.AccessApi3(api3);

            if (recapi3.status == 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
        public string Remote_InsertICPOEntry(MApiModel.api3.Rootobject getapi3)
        {
            try
            {
                MApiAccess.AccessApi Mapi = new MApiAccess.AccessApi();


                MApiModel.recToken.Rootobject g_token = new MApiModel.recToken.Rootobject();


                MApiModel.api1.Rootobject tempToken = new MApiModel.api1.Rootobject();
                tempToken.comid   = int.Parse(getapi3.comid);
                tempToken.action  = "getToken";
                tempToken.khhm    = "300384";
                tempToken.openkey = hn.Common.StringHelper.MD5string("10011630");
                g_token           = Mapi.AccessApi1(tempToken);


                LogHelper.WriteLog(JSONhelper.ToJson(g_token));

                getapi3.token = g_token.token;

                MApiModel.recApi3.Rootobject recapi3 = Mapi.AccessApi3(getapi3);
                LogHelper.WriteLog(JSONhelper.ToJson(recapi3));
                if (recapi3.status == 0)
                {
                    try
                    {
                        return(recapi3.resultInfo[0].pzhm);
                    }
                    catch
                    {
                        return("error:未返回编号");
                    }
                }
                else
                {
                    return("error:" + recapi3.msg);
                }
            }
            catch (Exception ee)
            {
                return("error:" + ee.ToString());
            }
        }
Ejemplo n.º 3
0
        public MApiModel.recApi3.Rootobject AccessApi3(MApiModel.api3.Rootobject api3)
        {
            // string strParam = Helper.getProperties<MApiModel.api3.Rootobject>(api3);
            List <string> listData = new List <string>();
            string        strData  = "";

            for (int i = 0; i < api3.data.Length; i++)
            {
                strData += JsonHelper.ObjectToJson(api3.data[i]);
                if (i != api3.data.Length - 1)
                {
                    strData += ",";
                }
            }



            string strParam = "comid=" + api3.comid + "&action=" + api3.action + "&token=" + api3.token + "&data=[" + strData + "]";

            string result = Helper.PostData(strParam);

            return(JsonHelper.ToObject <MApiModel.recApi3.Rootobject>(result));
        }
Ejemplo n.º 4
0
        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("请选择你要确认的数据!");
                }
            }
        }
Ejemplo n.º 5
0
 public string Remote_InsertICPOEntry(MApiModel.api3.Rootobject getapi3)
 {
     return(base.Channel.Remote_InsertICPOEntry(getapi3));
 }