Example #1
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            listClassType = DataCache.findAllDict().Where(model => model.ClassID == "MaterialType").ToList();
            listClassType.Insert(0, new ModelDictDetail()
            {
            });
        }
        string actiontype = Request["actiontype"];

        if (actiontype == "GetSpecManageList")
        {
            string Bh = Request["Bh"];
            if (!String.IsNullOrEmpty(Bh))
            {
                ccwhere.AddComponent("Bh", "%" + Bh + "%", SearchComponent.Like, SearchPad.And);
            }
            string Class = Request["Class"];
            if (!String.IsNullOrEmpty(Class))
            {
                ccwhere.AddComponent("Class", Class, SearchComponent.Equals, SearchPad.And);
            }
            string OrderNo = Request["OrderNo"];
            if (!String.IsNullOrEmpty(OrderNo))
            {
                ccwhere.AddComponent("OrderNo", "%" + OrderNo + "%", SearchComponent.Like, SearchPad.And);
            }



            int iPageCount = 0;
            int iPageIndex = int.Parse(Request["PageIndex"]) + 1;
            servComm.strOrderString = "Id desc ";
            listObj = servComm.GetList <ModelSpec>("Spec", "*", "Id", 10, iPageIndex, iPageCount, ccwhere);
            listObj.ToList().ForEach(eo => eo.Class = (listClassType.Where(le => le.Code == eo.Class).Count() > 0 ? listClassType.Where(le => le.Code == eo.Class).FirstOrDefault().DictName : ""));


            var timeConvert = new IsoDateTimeConverter();
            //timeConvert.DateTimeFormat = "yyyy-MM-dd HH:mm:ss";
            timeConvert.DateTimeFormat = "yyyy-MM-dd";


            string responseJson = JsonConvert.SerializeObject(listObj, Formatting.Indented, timeConvert);
            responseJson = responseJson.Replace(": null", ": \"\"");
            Response.Write("[{\"RowCount\":" + servComm.RowCount + ",\"JsonData\":" + responseJson + "}]");
            Response.End();
        }
        else if (actiontype == "ExportExcel")
        {
            string BillNo = Request["BillNo"];
            if (!String.IsNullOrEmpty(BillNo))
            {
                ccwhere.AddComponent("BillNo", "%" + BillNo + "%", SearchComponent.Like, SearchPad.And);
            }
            string Salesperson = Request["Salesperson"];
            if (!String.IsNullOrEmpty(Salesperson))
            {
                ccwhere.AddComponent("Salesperson", "%" + Salesperson + "%", SearchComponent.Like, SearchPad.And);
            }
            string IsDel = Request["IsDel"];
            if (!String.IsNullOrEmpty(IsDel))
            {
                ccwhere.AddComponent("IsDel", "1", SearchComponent.Equals, SearchPad.And);
            }
            else
            {
                ccwhere.AddComponent("Isnull(IsDel,0)", "1", SearchComponent.UnEquals, SearchPad.And);
            }

            servComm.strOrderString = "Id";
            listObj = servComm.GetListTop <ModelSpec>(0, "[Id],[SaleDate],[seller],[Salesperson],[BillDate],[BillNo],[BillClass],[Reg],[RegTime]", "Sale", ccwhere);
            string shortName = DateTime.Now.ToString("yyyyMMddHHmmsshhh") + ".xlsx";
            string fileName  = Request.PhysicalApplicationPath + "UploadFile\\" + shortName;
            using (NPOIHelper excelHelper = new NPOIHelper(fileName, Request.PhysicalApplicationPath + "UploadFile\\"))
            {
                DataTable dtTable = listObj.ToDataTable();
                dtTable.Columns.Remove("IsDel");
                int count = excelHelper.DataTableToExcel(dtTable, "订单信息", true);
            }
            Response.Write("http://" + Request.Url.Authority + "//UploadFile//" + shortName);
            Response.End();
        }
        else if (Request["actiontype"] == "SaveSpec")
        {
            int identityID = 0;
            try
            {
                ModelSpec ModelSpec = new ModelSpec();
                if (String.IsNullOrEmpty(Request["Id"]))
                {
                    ModelSpec.Class       = Request["Class"];
                    ModelSpec.Bh          = Request["Bh"];
                    ModelSpec.ProductName = Request["ProductName"];
                    ModelSpec.Spec        = Request["Spec"];
                    ModelSpec.OrderNo     = Request["OrderNo"];
                    ModelSpec.Size        = Request["Size"];
                    ModelSpec.exterior    = Request["exterior"];
                    ModelSpec.Color       = Request["Color"];
                    ModelSpec.Remark      = Request["Remark"];
                    identityID            = servComm.Add(ModelSpec);
                }
                else
                {
                    if (String.IsNullOrEmpty(Request["Bh"]))
                    {
                        identityID = servComm.ExecuteSql(" delete from Spec where ID in (" + Request["Id"] + ");");
                    }
                    else
                    {
                        identityID            = int.Parse(Request["Id"]);
                        ModelSpec.Class       = Request["Class"];
                        ModelSpec.Bh          = Request["Bh"];
                        ModelSpec.ProductName = Request["ProductName"];
                        ModelSpec.Spec        = Request["Spec"];
                        ModelSpec.OrderNo     = Request["OrderNo"];
                        ModelSpec.Size        = Request["Size"];
                        ModelSpec.exterior    = Request["exterior"];
                        ModelSpec.Color       = Request["Color"];
                        ModelSpec.Remark      = Request["Remark"];
                        ModelSpec.ID          = identityID;
                        int result = servComm.Update(ModelSpec);
                    }
                }
                DataCache.dict = servComm.GetListTop <ModelDictDetail>(0, null).ToList();
            }
            catch (Exception ex)
            {
                Response.Write(0);
                Response.End();
            }

            Response.Write(identityID);
            Response.End();
        }
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            ModelBase modelSale   = servComm.GetEntity <ModelBase>("1");
            var       timeConvert = new IsoDateTimeConverter();
            timeConvert.DateTimeFormat = "yyyy-MM-dd";
            string modelJson = JsonConvert.SerializeObject(modelSale, Formatting.Indented, timeConvert);

            EditJson = modelJson.Replace("\r\n", "");
        }
        string actiontype = Request["actiontype"];

        if (actiontype == "GetProductList")
        {
            servComm.strOrderString = "itemname collate Chinese_PRC_CS_AS_KS_WS";
            // ccWhere.AddComponent("Serial", LoginUser.Serial, SearchComponent.Equals, SearchPad.NULL);
            DataTable dtProduct   = servComm.GetListTop(0, "products", ccWhere);
            var       timeConvert = new IsoDateTimeConverter();
            //timeConvert.DateTimeFormat = "yyyy-MM-dd HH:mm:ss";
            timeConvert.DateTimeFormat = "yyyy-MM-dd";
            string responseJson = JsonConvert.SerializeObject(dtProduct, Formatting.Indented, timeConvert);
            Response.Write("[{\"RowCount\":" + servComm.RowCount + ",\"JsonData\":" + responseJson + "}]");
            Response.End();
        }
        else if (actiontype == "SaveBase")
        {
            int identityID = 1;
            try
            {
                ModelBase modelBase = new ModelBase();

                modelBase.ID        = 1;
                modelBase.corp      = Request["corp"].ToString();
                modelBase.Ecorp     = Request["Ecorp"].ToString();
                modelBase.Address   = Request["Address"];
                modelBase.Email     = Request["Email"];
                modelBase.fax       = Request["fax"];
                modelBase.LinkMan   = Request["LinkMan"];
                modelBase.netname   = Request["netname"];
                modelBase.phone     = Request["phone"];
                modelBase.ServerIP  = Request["ServerIP"];
                modelBase.ProductID = Request["ProductID"];
                modelBase.RoleA     = Request["RoleA"].Trim(':');
                modelBase.RoleB     = Request["RoleB"].Trim(':');
                modelBase.RoleC     = Request["RoleC"].Trim(':');
                modelBase.RoleD     = Request["RoleD"].Trim(':');
                servComm.Delete <ModelBase>("1", true);

                servComm.Add(modelBase);
            }
            catch (Exception ex)
            {
                Response.Write(0);
                Response.End();
            }

            Response.Write(identityID);
            Response.End();
        }
        else if (actiontype == "DeleteHisData")
        {
            try
            {
                string factoryEndDate = Request["factoryEndDate"];
                string salesEndDate   = Request["salesEndDate"];
                servComm.ExecuteSql("exec SP_DeleteHistory '" + factoryEndDate + "','" + salesEndDate + "'");
            }
            catch (Exception ex)
            {
                Response.Write(0);
                Response.End();
            }

            Response.Write("1");
            Response.End();
        }
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        if (Request["action"] == "CompareTalkRecord")
        {
            string unReadOrderNo = "";
            if (Session["allOrder"] == null)
            {
                Response.Write("");
                Response.End();
            }
            else
            {
                string[] orderNumber = Session["allOrder"].ToString().Trim(',').Split(',');
                for (int i = 0; i < orderNumber.Length; i++)
                {
                    if (Request.Cookies[LoginUser.BelongFactory + orderNumber[i]] != null && Request.Cookies[LoginUser.BelongFactory + orderNumber[i]].Value != "")
                    {
                        unReadOrderNo = GetLastedTimeByOrder(unReadOrderNo, orderNumber[i]);
                    }
                    else
                    {
                        unReadOrderNo = unReadOrderNo + "," + orderNumber[i];
                    }
                }
                Response.Write(unReadOrderNo.Trim(','));
                Response.End();
            }
        }

        if (Request["action"] == "ReadTalkRecord")
        {
            string orderNumber = Request["orderNumber"];
            string modifyDate  = GetLastedTimeByOrder("", orderNumber, "1");
            Response.Write(modifyDate);
            Response.End();
        }

        if (!IsPostBack)
        {
        }
        if (!string.IsNullOrEmpty(Request["hDelete"]))
        {
            servComm.ExecuteSql(" delete from W_Orders where ModelNo='" + Request["hDelete"] + "' and BelongFactory='" + LoginUser.BelongFactory + "'");
        }

        ccWhere.Clear();
        hddpnumbers = Request["hpnumbers"];
        int iCount = 10;

        if (!string.IsNullOrEmpty(hddpnumbers))
        {
            iCount = Convert.ToInt32(hddpnumbers);
        }
        int iPageIndex = string.IsNullOrEmpty(Request["sPageID"]) ? 1 : Convert.ToInt32(Request["sPageID"]);
        int iPageCount = string.IsNullOrEmpty(Request["sPageNum"]) ? 0 : Convert.ToInt32(Request["sPageNum"]);


        string txtModelNumber = Request["txtModelNumber"];

        if (!string.IsNullOrEmpty(txtModelNumber))
        {
            ccWhere.AddComponent("ModelNo ", "%" + txtModelNumber + "%", SearchComponent.Like, SearchPad.And);
        }

        string selectedID    = Request["selectedID"];
        string selectedLevel = Request["selectedLevel"];

        if (!String.IsNullOrEmpty(selectedLevel) && !String.IsNullOrEmpty(selectedID))
        {
            if (selectedLevel == "0")
            {
                ccWhere.AddComponent("sellerid ", selectedID, SearchComponent.Equals, SearchPad.And);
                ccMessageWhere.AddComponent("sellerid ", selectedID, SearchComponent.Equals, SearchPad.And);
            }
            else if (selectedLevel == "1")
            {
                ccWhere.AddComponent("HospitalID ", selectedID, SearchComponent.Equals, SearchPad.And);
                ccMessageWhere.AddComponent("HospitalID ", selectedID, SearchComponent.Equals, SearchPad.And);
            }
            else if (selectedLevel == "2")
            {
                ccWhere.AddComponent("DoctorID ", selectedID, SearchComponent.Equals, SearchPad.And);
                ccMessageWhere.AddComponent("DoctorID ", selectedID, SearchComponent.Equals, SearchPad.And);
            }
        }

        //被接收的订单不展示
        //ccWhere.AddComponent("isnull(Auth,'0') ", "0", SearchComponent.Equals, SearchPad.And);

        GetFilterByKind(ref ccWhere);
        GetFilterByKind(ref ccMessageWhere);

        servComm.strOrderString = " regtime desc ";
        IList <WORDERS> ilist = servComm.GetList <WORDERS>(WORDERS.STRTABLENAME, "*", WORDERS.STRKEYNAME, iCount, iPageIndex, iPageCount, ccWhere);

        ccMessageWhere.AddComponent("ModelNo", "(select OrderNumber from OrderMessage )", SearchComponent.In, SearchPad.And);
        IList <WORDERS> alllist    = servComm.GetListTop <WORDERS>(0, ccMessageWhere);
        string          strModelNo = "";

        alllist.ToList().ForEach(item => strModelNo = strModelNo + "," + item.ModelNo);
        Session["allOrder"]          = strModelNo;
        this.repOrderList.DataSource = ilist;
        repOrderList.DataBind();
        pagecut1.iPageNum = servComm.PageCount;
    }
Example #4
0
    protected void Page_Load(object sender, EventArgs e)
    {
        string actiontype = Request["actiontype"];

        if (!IsPostBack)
        {
            servComm.strOrderString = "Client";
            ccwhere.Clear();
            ccwhere.AddComponent("Class", "A", SearchComponent.Equals, SearchPad.NULL);
            ccwhere.AddComponent("Class", "B", SearchComponent.Equals, SearchPad.Or);
            listSeler = servComm.GetListTop <ModelClient>(0, ccwhere);
        }
        if (actiontype == "GetSaleList")
        {
            string BillNo = Request["BillNo"];
            ccwhere.Clear();
            if (!String.IsNullOrEmpty(BillNo))
            {
                ccwhere.AddComponent("BillNo", "%" + BillNo.Trim() + "%", SearchComponent.Like, SearchPad.And);
            }
            string Salesperson = Request["Salesperson"];
            if (!String.IsNullOrEmpty(Salesperson))
            {
                ccwhere.AddComponent("Salesperson", "%" + Salesperson.Trim() + "%", SearchComponent.Like, SearchPad.And);
            }
            string IsDel = Request["IsDel"];
            if (!String.IsNullOrEmpty(IsDel))
            {
                ccwhere.AddComponent("IsDel", "1", SearchComponent.Equals, SearchPad.And);
            }
            else
            {
                ccwhere.AddComponent("Isnull(IsDel,0)", "1", SearchComponent.UnEquals, SearchPad.And);
            }
            int    iPageCount   = 0;
            string strPageIndex = Request["PageIndex"] == null ? "0" : Request["PageIndex"];
            int    iPageIndex   = int.Parse(strPageIndex) + 1;
            servComm.strOrderString = "Id desc";
            listObj = servComm.GetList <ModelSale>("Sale", "*", "Id", 10, iPageIndex, iPageCount, ccwhere);
            listObj.ToList().ForEach(eo => eo.Seller = (listSeler.Where(le => le.Serial == eo.Seller).Count() > 0 ? listSeler.Where(le => le.Serial == eo.Seller).FirstOrDefault().Client : ""));


            var timeConvert = new IsoDateTimeConverter();
            //timeConvert.DateTimeFormat = "yyyy-MM-dd HH:mm:ss";
            timeConvert.DateTimeFormat = "yyyy-MM-dd";
            string responseJson = JsonConvert.SerializeObject(listObj, Formatting.Indented, timeConvert);
            responseJson = responseJson.Replace(": null", ": \"\"");
            Response.Write("[{\"RowCount\":" + servComm.RowCount + ",\"JsonData\":" + responseJson + "}]");

            Response.End();
        }
        else if (actiontype == "DisableOrderAction")
        {
            string Ids    = Request["CheckOrder"];
            string result = "0";
            try
            {
                servComm.ExecuteSql("update Sale set IsDel = 1 where Id in (" + Ids + ")");
                result = "1";
            }
            catch (Exception ex)
            {
                result = "0";
            }
            Response.Write(result);
            Response.End();
        }
        else if (actiontype == "ReuseOrderAction")
        {
            string Ids    = Request["CheckOrder"];
            string result = "0";
            try
            {
                servComm.ExecuteSql("update Sale set IsDel = 0 where Id in (" + Ids + ")");
                result = "1";
            }
            catch (Exception ex)
            {
                result = "0";
            }
            Response.Write(result);
            Response.End();
        }
        else if (actiontype == "ExportExcel")
        {
            ccwhere.Clear();
            string BillNo = Request["BillNo"];
            if (!String.IsNullOrEmpty(BillNo))
            {
                ccwhere.AddComponent("BillNo", "%" + BillNo + "%", SearchComponent.Like, SearchPad.And);
            }
            string Salesperson = Request["Salesperson"];
            if (!String.IsNullOrEmpty(Salesperson))
            {
                ccwhere.AddComponent("Salesperson", "%" + Salesperson + "%", SearchComponent.Like, SearchPad.And);
            }
            string IsDel = Request["IsDel"];
            if (!String.IsNullOrEmpty(IsDel))
            {
                ccwhere.AddComponent("IsDel", "1", SearchComponent.Equals, SearchPad.And);
            }
            else
            {
                ccwhere.AddComponent("Isnull(IsDel,0)", "1", SearchComponent.UnEquals, SearchPad.And);
            }

            servComm.strOrderString = "Id";
            string fieldShow = "[Id],[SaleDate],[seller],[Salesperson],[BillDate],[BillNo],[BillClass],[Addr],[receiver],[Tel],[distri],[distriNo],[Reg],[RegTime]";
            listObj = servComm.GetListTop <ModelSale>(0, fieldShow, "Sale", ccwhere);
            string shortName = DateTime.Now.ToString("yyyyMMddHHmmsshhh") + ".xlsx";
            string fileName  = Request.PhysicalApplicationPath + "UploadFile\\" + shortName;
            using (NPOIHelper excelHelper = new NPOIHelper(fileName, Request.PhysicalApplicationPath + "UploadFile\\"))
            {
                DataTable dt         = new DataTable();
                string[]  splitField = fieldShow.Split(',');
                for (int i = 0; i < splitField.Length; i++)
                {
                    dt.Columns.Add(splitField[i].Trim('[').Trim(']'));
                }

                DataTable dtTable = listObj.ToDataTable(dt);
                //dtTable.Columns.Remove("IsDel");
                int count = excelHelper.DataTableToExcel(dtTable, "订单信息", true);
            }
            Response.Write("http://" + Request.Url.Authority + "//UploadFile//" + shortName);
            Response.End();
        }
    }
Example #5
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (Request.HttpMethod == "POST")
        {
            // 使用Dictionary保存参数
            Hashtable myMap = new Hashtable();

            NameValueCollection coll = Request.Form;

            string[] requestItem = coll.AllKeys;

            for (int i = 0; i < requestItem.Length; i++)
            {
                myMap.Add(requestItem[i], Request.Form[requestItem[i]]);
            }

            if (myMap.ContainsKey("MerId"))
            {
                chinapaysecure.SecssUtil obj = new chinapaysecure.SecssUtil();
                ccWhere.Clear();
                ccWhere.AddComponent("PayNoCardMerId", myMap["MerId"].ToString(), SearchComponent.Equals, SearchPad.NULL);
                int count = servComm.GetCount("JX_USERS", ccWhere);
                if (count > 0)
                {
                    obj.init(Request.PhysicalApplicationPath + "ChinaPay/" + myMap["MerId"].ToString() + "/security.properties"); //初始化安全控件:
                }
                else
                {
                    //B2C支付
                    //myMap.Add("BankInstNo", "700000000000010");
                    //myMap.Add("MerId", "481601512177911");
                    obj.init(Request.PhysicalApplicationPath + "ChinaPay/" + myMap["MerId"].ToString() + "/securityb2c.properties"); //初始化安全控件:
                }
                obj.verify(myMap);
                // 返回报文中不包含UPOG,表示Server端正确接收交易请求,则需要验证Server端返回报文的签名
                if ("00" == obj.getErrCode())
                {
                    servComm.ExecuteSql("update W_NetPay set PayDateTime = getdate() ,PayStatus = 2 where OrderID = '" + myMap["MerOrderNo"].ToString() + "'");


                    //Response.Write("商户端验证返回报文签名成功\n");

                    //商户端根据返回报文内容处理自己的业务逻辑 ,DEMO此处只输出报文结果
                    //StringBuilder builder = new StringBuilder();

                    //builder.Append("<tr><td align=\"center\" colspan=\"2\"><b>商户端接收银联返回报文并按照表格形式输出结果</b></td></tr>");

                    //for (int i = 0; i < requestItem.Length; i++)
                    //{
                    //    builder.Append("<tr><td width=\"30%\" align=\"right\">" + requestItem[i] + "</td><td style='word-break:break-all'>" + Request.Form[requestItem[i]] + "</td></tr>");
                    //}

                    //builder.Append("<tr><td width=\"30%\" align=\"right\">商户端验证银联返回报文结果</td><td>验证签名成功.</td></tr>");
                    //Response.Write(builder.ToString());
                }
                else
                {
                    servComm.ExecuteSql("update W_NetPay set PayDateTime = getdate() ,PayStatus = 9 where OrderID = '" + myMap["MerOrderNo"].ToString() + "'");

                    Response.Write("<tr><td width=\"30%\" align=\"right\">商户端验证银联返回报文结果</td><td>验证签名失败.</td></tr>");
                }
            }
        }

        ccWhere.Clear();
        ccWhere.AddComponent("UserID", CurrentUserID.ToString(), SearchComponent.Equals, SearchPad.NULL);
        if (!String.IsNullOrEmpty(Request["txtOrderNumner"]))
        {
            ccWhere.AddComponent("OrderID", Request["txtOrderNumner"], SearchComponent.Like, SearchPad.And);
        }

        hddpnumbers = Request["hpnumbers"];
        int iCount = 10;

        if (!string.IsNullOrEmpty(hddpnumbers))
        {
            iCount = Convert.ToInt32(hddpnumbers);
        }
        int iPageIndex = string.IsNullOrEmpty(Request["sPageID"]) ? 1 : Convert.ToInt32(Request["sPageID"]);
        int iPageCount = string.IsNullOrEmpty(Request["sPageNum"]) ? 0 : Convert.ToInt32(Request["sPageNum"]);

        servComm.strOrderString = " ID desc ";
        IList <WNetPay> ilist = servComm.GetList <WNetPay>(WNetPay.STRTABLENAME, "*", WNetPay.STRKEYNAME, iCount, iPageIndex, iPageCount, ccWhere);

        repUserList.DataSource = ilist;
        repUserList.DataBind();
        pagecut1.iPageNum = servComm.PageCount;
    }
Example #6
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            ccwhere.Clear();
            ccwhere.AddComponent("Class", "B", SearchComponent.Equals, SearchPad.NULL);
            listSeler   = servComm.GetListTop <ModelClient>(0, "*", "Client", ccwhere);
            BindingJson = JsonConvert.SerializeObject(listSeler, Formatting.Indented, new IsoDateTimeConverter());

            BindingJson = BindingJson.Replace("\r\n", "").Replace("Client", "NodeName");
        }
        string actiontype = Request["actiontype"];

        if (actiontype == "GetSaleList")
        {
            ConstructionCondition();

            int iPageCount = 0;
            int iPageIndex = int.Parse(Request["PageIndex"]) + 1;
            servComm.strOrderString = "CardNo";
            listObj = servComm.GetList <ModelOrders>("orders", "*", "CardNo", 10, iPageIndex, iPageCount, ccwhere);
            listObj.ToList().ForEach(eo => eo.Serial = (listSeler.Where(le => le.Serial == eo.Serial).Count() > 0 ? listSeler.Where(le => le.Serial == eo.Serial).FirstOrDefault().Client : ""));

            var timeConvert = new IsoDateTimeConverter();
            //timeConvert.DateTimeFormat = "yyyy-MM-dd HH:mm:ss";
            timeConvert.DateTimeFormat = "yyyy-MM-dd";
            string responseJson = JsonConvert.SerializeObject(listObj, Formatting.Indented, timeConvert);
            responseJson = responseJson.Replace(": null", ": \"\"");
            Response.Write("[{\"RowCount\":" + servComm.RowCount + ",\"JsonData\":" + responseJson + "}]");
            Response.End();
        }
        else if (actiontype == "GetOrderDetail")
        {
            servComm.strOrderString = "CardNo";
            ccwhere.Clear();
            string CardNo = Request["CardNo"];
            ccwhere.AddComponent("CardNo", CardNo, SearchComponent.Equals, SearchPad.NULL);
            IList <ModelOrdersDetail> listObj = servComm.GetListTop <ModelOrdersDetail>(0, "*", "OrdersDetail", ccwhere);
            var timeConvert = new IsoDateTimeConverter();
            //timeConvert.DateTimeFormat = "yyyy-MM-dd HH:mm:ss";
            timeConvert.DateTimeFormat = "yyyy-MM-dd";
            string responseJson = JsonConvert.SerializeObject(listObj, Formatting.Indented, timeConvert);
            responseJson = responseJson.Replace(": null", ": \"\"");
            responseJson = responseJson.Replace("\r\n", "");
            Response.Write(responseJson);
            Response.End();
        }
        else if (actiontype == "ExportExcel")
        {
            ConstructionCondition();

            servComm.strOrderString = "CardNo";
            DataTable dtTable   = servComm.GetListTop(0, "*", "ViewOrders", ccwhere);
            string    shortName = DateTime.Now.ToString("yyyyMMddHHmmsshhh") + ".xlsx";
            string    fileName  = Request.PhysicalApplicationPath + "UploadFile\\" + shortName;
            using (NPOIHelper excelHelper = new NPOIHelper(fileName, Request.PhysicalApplicationPath + "UploadFile\\"))
            {
                int count = excelHelper.DataTableToExcel(dtTable, "工厂订单信息", true, "工厂订单信息.xlsx");
            }
            Response.Write("http://" + Request.Url.Authority + "//UploadFile//" + shortName);
            Response.End();
        }
        else if (actiontype == "GetProductList")
        {
            ccwhere.Clear();
            ccwhere.AddComponent("Serial", LoginUser.Serial, SearchComponent.Equals, SearchPad.NULL);
            servComm.strOrderString = "itemname collate Chinese_PRC_CS_AS_KS_WS";
            // ccWhere.AddComponent("Serial", LoginUser.Serial, SearchComponent.Equals, SearchPad.NULL);
            DataTable dtProduct   = servComm.GetListTop(0, "products", ccwhere);
            var       timeConvert = new IsoDateTimeConverter();
            //timeConvert.DateTimeFormat = "yyyy-MM-dd HH:mm:ss";
            timeConvert.DateTimeFormat = "yyyy-MM-dd";
            string responseJson = JsonConvert.SerializeObject(dtProduct, Formatting.Indented, timeConvert);
            Response.Write("[{\"RowCount\":" + dtProduct.Rows.Count + ",\"JsonData\":" + responseJson + "}]");
            Response.End();
        }
        else if (actiontype == "SaveProduct")
        {
            int identityID = 1;
            try
            {
                string productID = Request["ProductID"];
                if (!String.IsNullOrEmpty(productID))
                {
                    servComm.ExecuteSql("update client set productID = '" + productID + "' where Serial = '" + LoginUser.Serial + "'");
                }
            }
            catch (Exception ex)
            {
                Response.Write(0);
                Response.End();
            }

            Response.Write(identityID);
            Response.End();
        }
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        facComm = new ServiceCommon(factoryConnectionString);
        if (!IsPostBack)
        {
            if (Request["action"] == null)
            {
                Session["productList"] = null;
            }

            ddlOrderType.DataSource = BindDictClass(facComm, ccWhere, "OrderClass");
            ddlOrderType.DataBind();
        }



        if (Request["action"] == "autoNo")
        {
            DataTable dtNumber = servComm.ExecuteSqlDatatable("select dbo.fn_GetAutoOrderNo(N'" + LoginUser.UserName + "','" + DateTime.Now.ToString("yyMMdd") + "','" + LoginUser.BelongFactory + "')");
            if (dtNumber.Rows.Count > 0)
            {
                Response.Write(dtNumber.Rows[0][0].ToString().Trim());
                Response.End();
            }
            else
            {
                Response.Write("");
                Response.End();
            }
        }


        if (Request["action"] == "checkUnique")
        {
            DataTable dtNumber = servComm.ExecuteSqlDatatable("select ModelNo from W_Orders where ModelNo='" + Request["orderNo"].Replace("'", "") + "' and BelongFactory='" + LoginUser.BelongFactory + "'");
            if (dtNumber.Rows.Count > 0)
            {
                Response.Write("1");
            }
            else
            {
                Response.Write("0");
            }
            Response.End();
        }

        if (Request["action"] == "GetRequireTemplate")
        {
            string temlplate = Request["temlplate"];
            if (String.IsNullOrEmpty(temlplate))
            {
                Response.Write("");
            }
            else
            {
                DataTable dtRequire = servComm.ExecuteSqlDatatable("select RequireTemplateContent from W_RequireTemplate where id =" + temlplate);
                if (dtRequire.Rows.Count > 0)
                {
                    Response.Write(dtRequire.Rows[0][0].ToString());
                }
                else
                {
                    Response.Write("");
                }
            }
            Response.End();
        }

        BindRequireTemplate();
        BindSeller();

        if (String.IsNullOrEmpty(yeyRequest.Params("haddinfo")) && !String.IsNullOrEmpty(Request["ModelNo"]))
        {
            autoOrderNo.Visible = false;
            autoLable.Visible   = false;
            ccWhere.Clear();
            ccWhere.AddComponent("ModelNo", Request["ModelNo"], SearchComponent.Equals, SearchPad.NULL);
            ordreModel = servComm.GetListTop <WORDERS>(1, ccWhere)[0];

            if (ordreModel.SellerID != 0)
            {
                this.ddlSeller.SelectedValue = ordreModel.SellerID.ToString();
            }

            ddlOrderType.Value = ordreModel.OrderClass;
            //strOtherList
            ccWhere.Clear();
            ccWhere.AddComponent("ModelNo", Request["ModelNo"], SearchComponent.Equals, SearchPad.NULL);
            IList <WORDERSOTHER> listOther = servComm.GetListTop <WORDERSOTHER>(0, ccWhere);
            foreach (WORDERSOTHER item in listOther)
            {
                strOtherList = strOtherList + ":" + item.Code + "," + item.qty;
            }
            if (strOtherList != "")
            {
                strOtherList = strOtherList.Substring(1);
            }
            servComm.strOrderString = " subId asc ";
            List <WORDERSDETAIL> listOrders = (List <WORDERSDETAIL>)servComm.GetListTop <WORDERSDETAIL>(0, "*", ccWhere);
            foreach (WORDERSDETAIL item in listOrders)
            {
                string strValue = GetProductName(item.ProductId);
                if (strValue != "")
                {
                    item.ItemName   = strValue.Split(',')[0];
                    item.SmallClass = strValue.Split(',')[1];
                }
            }
            this.repProductList.DataSource = listOrders;
            this.repProductList.DataBind();
            Session["productList"]  = listOrders;
            servComm.strOrderString = "";
            ccWhere.Clear();
            ccWhere.AddComponent("ModelNo", Request["ModelNo"], SearchComponent.Equals, SearchPad.NULL);
            IList <WORDERSPHOTOS> listPhotos = servComm.GetListTop <WORDERSPHOTOS>(0, ccWhere);
            foreach (WORDERSPHOTOS item in listPhotos)
            {
                strPhotoList = strPhotoList + "," + item.picpath;
            }
            if (strPhotoList != "")
            {
                strPhotoList = strPhotoList.Substring(1);
            }
        }

        if (yeyRequest.Params("haddinfo") == "1")
        {
            ordreModel.ModelNo    = Request["txtModelNo"];
            ordreModel.OrderClass = Request[this.ddlOrderType.UniqueID];
            ordreModel.SellerID   = decimal.Parse(Request[this.ddlSeller.UniqueID]);
            ordreModel.HospitalID = decimal.Parse(Request[this.ddlHosipital.UniqueID]);
            ordreModel.DoctorId   = decimal.Parse(Request[this.ddlDoctor.UniqueID]);
            ordreModel.Patient    = Request["txtpatient"];
            if (Request["txtAge"] != "")
            {
                ordreModel.Age = decimal.Parse(Request["txtAge"]);
            }
            ordreModel.Sex           = Request["ddlSex"];
            ordreModel.danzuo        = Request["ddlSingle"];
            ordreModel.Fenge         = Request["ddlDivision"];
            ordreModel.Require       = Request["Require"].Replace("'", "");
            ordreModel.RegTime       = DateTime.Now;
            ordreModel.RegName       = LoginUser.UserName;
            ordreModel.BelongFactory = LoginUser.BelongFactory;
            if (!String.IsNullOrEmpty(yeyRequest.Params("keyID")))
            {
                servComm.Update(ordreModel);
            }
            else
            {
                servComm.Add(ordreModel);
            }


            string AccessoryList = Request["OtherList"];
            if (AccessoryList != "")
            {
                servComm.ExecuteSql(" delete from W_ordersOther where ModelNo='" + Request["txtModelNo"] + "'and BelongFactory = '" + LoginUser.BelongFactory + "'");
                string[]     otherSplit = AccessoryList.Split(':');
                WORDERSOTHER otherModel = new WORDERSOTHER();
                ccWhere.Clear();
                ccWhere.AddComponent("ClassID", "Accessory", SearchComponent.Equals, SearchPad.NULL);
                DataTable dtAccessory = facComm.GetListTop(0, "DictDetail", ccWhere);
                for (int i = 0; i < otherSplit.Length; i++)
                {
                    string accessoryName = "";
                    if (dtAccessory.Select("Code = '" + otherSplit[i].Split(',')[0] + "'").Length > 0)
                    {
                        accessoryName = dtAccessory.Select("Code = '" + otherSplit[i].Split(',')[0] + "'")[0]["DictName"].ToString();
                    }
                    otherModel.ModelNo       = Request["txtModelNo"];
                    otherModel.SubId         = i + 1;
                    otherModel.Code          = otherSplit[i].Split(',')[0];
                    otherModel.name          = accessoryName;
                    otherModel.qty           = decimal.Parse(otherSplit[i].Split(',')[1]);
                    otherModel.BelongFactory = LoginUser.BelongFactory;
                    servComm.Add(otherModel);
                }
            }
            string photoList = Request["photoList"];
            if (photoList != "")
            {
                servComm.ExecuteSql(" delete from W_OrderPhotos where ModelNo='" + Request["txtModelNo"] + "' and BelongFactory = '" + LoginUser.BelongFactory + "'");
                string[]      otherSplit = photoList.Split(',');
                WORDERSPHOTOS photoModel = new WORDERSPHOTOS();
                for (int i = 0; i < otherSplit.Length; i++)
                {
                    photoModel.ModelNo       = Request["txtModelNo"];
                    photoModel.SubId         = i + 1;
                    photoModel.picpath       = otherSplit[i].Split(',')[0];
                    photoModel.BelongFactory = LoginUser.BelongFactory;
                    servComm.Add(photoModel);
                }
            }


            int index = 1;
            IList <WORDERSDETAIL> listOrders = (IList <WORDERSDETAIL>)Session["productList"];

            if (listOrders != null)
            {
                servComm.ExecuteSql(" delete from W_OrdersDetail where ModelNo='" + Request["txtModelNo"] + "'and BelongFactory = '" + LoginUser.BelongFactory + "'");

                foreach (WORDERSDETAIL item in listOrders)
                {
                    item.subId         = index;
                    item.ModelNo       = Request["txtModelNo"];
                    item.BelongFactory = LoginUser.BelongFactory;
                    servComm.Add(item);
                    index = index + 1;
                }
            }

            Response.Redirect("OrderList.aspx?type=Order");
        }
    }