public ServerResponse <string> LockAuthority(JObject form)
 {
     if (_zl11Repository.GetCtrl("QSBN_LOCK", "01").drpValue.Contains(GetUser()))
     {
         return(ServerResponse <string> .CreateBySuccessMessage("OK!"));
     }
     else
     {
         return(ServerResponse <string> .CreateByErrorMessage("操作错误,仅关务有加锁和解锁的权限 !"));
     }
 }
 public ServerResponse <string> LockClick(JObject form)
 {
     try
     {
         _zl11Repository.LockClick(form["BUKRS"].ToString(), form["MATNR"].ToString(), form["Vendorcode"].ToString(), form["Type"].ToString(), form["LOCK"].ToString());
         return(ServerResponse <string> .CreateBySuccessMessage("Success"));
     }
     catch (Exception e)
     {
         return(ServerResponse <string> .CreateByErrorMessage("Error" + e.Message));
     }
 }
        public ServerResponse <JArray> Query(JObject form)
        {
            //TODO。。。判空
            //太慢
            var result = _zl11Repository.Query(form);

            if (result == null || result.Count() == 0)
            {
                return(ServerResponse <JArray> .CreateByErrorMessage("无数据!"));
            }
            else
            {
                return(ServerResponse <JArray> .CreateBySuccess(JArray.FromObject(_zl11Repository.Query(form))));
            }
        }
        public ServerResponse <string> Delete(JObject form)
        {
            JArray forms     = JArray.FromObject(form["data"]);
            var    delReason = form["delReason"].ToString();

            try
            {
                foreach (var data in forms)
                {
                    _zl11Repository.Delete(form["Type"].ToString(), form["MANDT"].ToString(),
                                           form["BUKRS"].ToString(), form["MATNR"].ToString(), form["Vendorcode"].ToString(), form["DECLITEM"].ToString(),
                                           GetUser(), delReason);
                }

                return(ServerResponse <string> .CreateBySuccessMessage("删除成功!"));
            }
            catch
            {
                return(ServerResponse <string> .CreateByErrorMessage("删除失败!"));
            }
        }
        public ServerResponse <string> Save(JArray form)
        {
            var    userName              = GetUser();
            string strBeiZhu             = "";
            bool   flag                  = false;
            IList <VIEW_spare_All> zl11s = form.ToObject <IList <VIEW_spare_All> >();

            foreach (var zl11 in zl11s)
            {
                zl11.CHNAME = userName;
                zl11.CHDATE = DateTime.Now.Date.ToString("yyyyMMdd");

                if (!zl11.Type.Equals("放弃退税") &&
                    _zl11Repository.CheckDiff(zl11.BUKRS, zl11.MATNR, zl11.SMAKTX, zl11.TAX_CODE, zl11.CGEWEI, zl11.DECLITEM) &&
                    !_zl11Repository.GetCtrl("QSBN_CheckDiff", "01").drpValue.Contains(userName))
                {
                    return(ServerResponse <string> .CreateByErrorMessage("料号" + zl11.MATNR + "备案不一致,请确认!"));
                }

                #region 国内Vendor Beizhu必填  境外Vendor 能效标识必填
                if (zl11.Vendorcode.Equals("QCI_MRO") || zl11.Vendorcode.Substring(zl11.Vendorcode.Length - 1, 1) == "F")
                {
                    if ((_tdsYitemRepository.Is3C(zl11.BUKRS, zl11.DECLITEM) & zl11.C3FLAG == "不涉及")
                        & (_tdsYitemRepository.IsEnergy(zl11.BUKRS, zl11.DECLITEM) & zl11.CELFLAG == "不涉及"))
                    {
                        strBeiZhu += "【" + zl11.BUKRS + ',' + zl11.DECLITEM + ',' + zl11.MATNR + "涉及3C验证;"
                                     + zl11.Vendorcode + ',' + zl11.MATNR + "涉及能效标识" + "】";
                    }
                    else if ((_tdsYitemRepository.Is3C(zl11.BUKRS, zl11.DECLITEM) & zl11.C3FLAG == "不涉及"))
                    {
                        strBeiZhu += "【" + zl11.BUKRS + ',' + zl11.DECLITEM + ',' + zl11.MATNR + "涉及3C验证】";
                    }
                    else if (_tdsYitemRepository.IsEnergy(zl11.BUKRS, zl11.DECLITEM) & zl11.CELFLAG == "不涉及")
                    {
                        strBeiZhu += "【" + zl11.BUKRS + ',' + zl11.Vendorcode + ',' + zl11.MATNR + "涉及能效标识" + "】";
                    }
                    else
                    {
                        if (zl11.BRGEW != "")//BRGEW zhengsui
                        {
                            strBeiZhu += "【" + zl11.BUKRS + ',' + zl11.Vendorcode + ',' + zl11.MATNR + "涉及" + zl11.BRGEW + "】";
                        }
                        flag = InsertMro(zl11);
                    }
                }
                else if (zl11.Vendorcode.Substring(zl11.Vendorcode.Length - 1, 1) == "L" ||
                         zl11.Vendorcode != "QCI_MRO")
                {
                    if (zl11.C3REMARK == "无备注")
                    {
                        strBeiZhu += "【" + zl11.BUKRS + ',' + zl11.Vendorcode + ',' + zl11.MATNR + "备注栏位必填" + "】";
                    }
                    else
                    {
                        flag = InsertMro(zl11);
                    }
                }

                #endregion
            }

            //todo...有问题,循环插入没办法判断是否保存成功
            if (flag)
            {
                return(ServerResponse <string> .CreateBySuccessMessage("Save Successfully" + strBeiZhu));
            }
            else
            {
                return(ServerResponse <string> .CreateByErrorMessage("Save Error" + strBeiZhu));
            }
        }
        public ServerResponse <string> Save(JArray forms)
        {
            IList <tdsAupo> tdsAupos = new List <tdsAupo>();
            string          user     = GetUser();


            if (string.IsNullOrEmpty(user))
            {
                return(ServerResponse <string> .CreateByErrorMessage("请求超时,请刷新主页重进!"));
            }
            foreach (var form in forms)
            {
                if (form["REMARK"].ToString().Equals("申请人确认抽单") && string.IsNullOrEmpty(form["DECLITEM"].ToString()))
                {
                }
                else
                {
                    # region 境外po
                    if (form["LIFNR"].ToString().Equals("QCI_MRO") ||
                        form["LIFNR"].ToString().Substring(form["LIFNR"].ToString().Length - 1, 1) == "F")   //境外PO
                    {
                        if (_tdsYitemRepository.Is3C(form["BUKRS"].ToString(), form["DECLITEM"].ToString()) &&
                            form["MARK"].ToString().Equals("0"))
                        {
                            return(ServerResponse <string> .CreateByErrorMessage("此序号涉及3C认证!不能设置为不涉及!"));
                        }
                        if (_tdsYitemRepository.IsEnergy(form["BUKRS"].ToString(), form["DECLITEM"].ToString()) &&
                            form["CELFLAG"].ToString().Equals("0"))
                        {
                            return(ServerResponse <string> .CreateByErrorMessage("此序号涉及能源标识!不能设置为不涉及!"));
                        }
                    }
                    #endregion
                    #region 境内po
                    else
                    {
                        string strFlag = _tdsYitemRepository.IsMonitorRule(form["BUKRS"].ToString(), form["DECLITEM"].ToString());
                        if (strFlag != "")
                        {
                            switch (strFlag)
                            {
                            case "3":
                                return(ServerResponse <string> .CreateByErrorMessage("此序号涉及证件:3两用物项和技术出口许可证 "));

                                break;

                            case "4":
                                return(ServerResponse <string> .CreateByErrorMessage("此序号涉及证件:4出口许可证"));

                                break;

                            case "8":
                                return(ServerResponse <string> .CreateByErrorMessage("此序号涉及证件:8禁止出口商品"));

                                break;

                            case "G":
                                return(ServerResponse <string> .CreateByErrorMessage("此序号涉及证件:G两用物项和技术出口许可证(定向)"));

                                break;

                            default:
                                break;
                            }
                        }
                    }
                    #endregion
                    if (form["vendortype"].ToString() == "自主报关" || form["vendortype"].ToString() == "代理报关")
                    {
                        #region  料号的po:当有料号的po: 自主报关、代理报关、 在归类有料号的PO时,系统校验公司别+料号是否存在不一致的底账序号,如果有,系统提示;如果没有,系统保存成功
                        if (form["matnrE"].ToString() != "COASSET" && form["matnrE"].ToString() != "FOCCONSU" && form["matnrE"].ToString() != "")
                        {
                            if (!_tdsAupoRepository.IsExistZl11(form["BUKRS"].ToString(), form["matnrE"].ToString(), form["LIFNR"].ToString()))
                            {
                                return(ServerResponse <string> .CreateByErrorMessage("料号:" + form["matnrE"].ToString() + "在ZL11未备案!"));
                            }
                            if (!_tdsAupoRepository.SameDecMatnr(form["BUKRS"].ToString(), form["LIFNR"].ToString(), form["matnrE"].ToString(), form["DECLITEM"].ToString()))
                            {
                                return(ServerResponse <string> .CreateByErrorMessage("归并序号与ZL11序号不一致,请核实!"));
                            }
                            if (!_tdsAupoRepository.SameDecDiffEbeln(form["BUKRS"].ToString(), form["matnrE"].ToString(), form["DECLITEM"].ToString()))
                            {
                                if ((user != "03070472" && user != "06030239" && user != "A0070028" && user != "A0070116" && user != "A7100040" && user != "QSBN"))
                                {
                                    return(ServerResponse <string> .CreateByErrorMessage("相同料号,不同PO中的底账序号不一致!"));
                                }
                            }
                        }
                        #endregion
                        #region 无料号po:当没有料号的po:自主报关、代理报关、 同厂区(QSMC及QCMC公司别)、同VENDOR CODE、同Shorttext、归并底账序号不同时,无法保存
                        else
                        {
                            if (!"TFC_MRO,TFQ_MRO,TCC_MRO,TLC_MRO,TGC_MRO,TWW_MRO,TWQ_MRO,ZYS_MRO,ZYQ_MRO".Contains(form["LIFNR"].ToString()))
                            {
                                if (!_tdsAupoRepository.PoCheck(form["BUKRS"].ToString(), form["LIFNR"].ToString()
                                                                , form["TXZ01"].ToString(), form["EBELN"].ToString()
                                                                , form["vendortype"].ToString(), form["DECLITEM"].ToString()) &&
                                    !"03070472,A0070028,A2132386,A0070116,06030239,QSBN,A7100040".Contains(user))
                                {
                                    return(ServerResponse <string> .CreateByErrorMessage("ITEM:" + form["EBELP"].ToString() + "相同Short text已归并过底账序号:" + form["DECLITEM"].ToString() + ",请确认"));
                                }
                            }
                        }
                        #endregion
                    }
                    #region 判断是否做过EC单1
                    if (_tdsAupoRepository.ECCheck(form["BUKRS"].ToString(), form["EBELN"].ToString(), form["EBELP"].ToString()))
                    {
                        return(ServerResponse <string> .CreateByErrorMessage("该PO已做过EC单!"));
                    }
                    #endregion
                }
                tdsAupo tdsAupo = new tdsAupo();
                tdsAupo.MANDT = form["MANDT"].ToString();
                tdsAupo.BUKRS = form["BUKRS"].ToString();

                tdsAupo.EBELN = form["EBELN"].ToString();
                //tdsAupo.EBELN = "111111111";
                tdsAupo.EBELP        = form["EBELP"].ToString();
                tdsAupo.DECLITEM     = form["DECLITEM"].ToString();
                tdsAupo.MATNR        = form["MATNR"].ToString();
                tdsAupo.E_I          = "I";
                tdsAupo.TAX_CODE     = form["TAX_CODE"].ToString();
                tdsAupo.ZGEWEI       = form["ZGEWEI"].ToString();
                tdsAupo.SMAKTX       = form["SMAKTX"].ToString();
                tdsAupo.APPQTY       = form["APPQTY"].ToObject <decimal>();
                tdsAupo.DECLQTY      = form["DECLQTY"].ToObject <decimal>();
                tdsAupo.APFLAG       = form["APFLAG"].ToString();
                tdsAupo.STATUS       = form["STATUS"].ToString();
                tdsAupo.MARK         = form["MARK"].ToString();
                tdsAupo.REMARK       = form["REMARK"].ToString();
                tdsAupo.CHDATE       = DateTime.Now;
                tdsAupo.CHNAME       = user;
                tdsAupo.ZHENGSHUI    = form["BRGEW"].ToString();
                tdsAupo.HOMEORABROAD = string.Empty;
                tdsAupo.CELFLAG      = form["CELFLAG"].ToString();
                tdsAupo.ACCNO        = form["BOITYP"].ToString();
                tdsAupos.Add(tdsAupo);
                // 管制
                string retrc = form["RETRC"].ToString();
                // 新旧
                string itemno = form["STATUS"].ToString();
                _tdsAupoRepository.UpdateOtherDatas(tdsAupo, retrc, itemno);
            }