Exemplo n.º 1
0
        private string validaction(JsonArrayParse jp)
        {
            JsonObjectCollection collection = new JsonObjectCollection();
            string flag = "1";

            try
            {
                Business.Base.BusinessCustInfo bc = new project.Business.Base.BusinessCustInfo();
                bc.load(jp.getValue("id"));
                bc.Entity.Valid = !bc.Entity.Valid;

                int r = bc.valid();
                if (r <= 0)
                {
                    flag = "2";
                }
                if (bc.Entity.Valid)
                {
                    collection.Add(new JsonStringValue("stat", "<span class=\"label label-success radius\">有效</span>"));
                }
                else
                {
                    collection.Add(new JsonStringValue("stat", "<span class=\"label radius\">已失效</span>"));
                }
                collection.Add(new JsonStringValue("id", jp.getValue("id")));
            }
            catch { flag = "2"; }

            collection.Add(new JsonStringValue("flag", flag));
            collection.Add(new JsonStringValue("type", "valid"));
            return(collection.ToString());
        }
Exemplo n.º 2
0
        private string deleteaction(JsonArrayParse jp)
        {
            JsonObjectCollection collection = new JsonObjectCollection();
            string flag = "1";

            try
            {
                Business.Base.BusinessCustInfo bc = new project.Business.Base.BusinessCustInfo();
                bc.load(jp.getValue("id"));

                if (obj.ExecuteDataSet("select 1 from WO_WorkOrder where CustNo='" + bc.Entity.CustNo + "' and AccID='" + user.Entity.AccID + "'").Tables[0].Rows.Count > 0)
                {
                    flag = "3";
                }
                else
                {
                    int r = bc.delete();
                    if (r <= 0)
                    {
                        flag = "2";
                    }
                }
            }
            catch { flag = "2"; }

            collection.Add(new JsonStringValue("type", "delete"));
            collection.Add(new JsonStringValue("flag", flag));
            collection.Add(new JsonStringValue("liststr", createList(jp.getValue("CustNameS"), int.Parse(jp.getValue("page")))));

            return(collection.ToString());
        }
Exemplo n.º 3
0
        private string updateaction(JsonArrayParse jp)
        {
            JsonObjectCollection collection = new JsonObjectCollection();
            string flag   = "1";
            string result = "";;

            try
            {
                Business.Base.BusinessCustInfo bc = new project.Business.Base.BusinessCustInfo();
                bc.load(jp.getValue("id"));

                collection.Add(new JsonStringValue("CustNo", bc.Entity.CustNo));
                collection.Add(new JsonStringValue("CustName", bc.Entity.CustName));
                collection.Add(new JsonStringValue("CustType", bc.Entity.CustType));
                collection.Add(new JsonStringValue("Contact", bc.Entity.Contact));
                collection.Add(new JsonStringValue("Tel", bc.Entity.Tel));
                collection.Add(new JsonStringValue("Addr", bc.Entity.Addr));
                collection.Add(new JsonStringValue("Website", bc.Entity.Website));
                collection.Add(new JsonStringValue("Remark", bc.Entity.Remark));
            }
            catch
            { flag = "2"; }

            collection.Add(new JsonStringValue("type", "update"));
            collection.Add(new JsonStringValue("flag", flag));

            result = collection.ToString();

            return(result);
        }
Exemplo n.º 4
0
        private string submitaction(JsonArrayParse jp)
        {
            JsonObjectCollection collection = new JsonObjectCollection();
            string flag = "1";

            try
            {
                Business.Base.BusinessCustInfo bc = new project.Business.Base.BusinessCustInfo();
                if (jp.getValue("tp") == "update")
                {
                    bc.load(jp.getValue("id"));
                    bc.Entity.CustName = jp.getValue("CustName");
                    bc.Entity.CustType = jp.getValue("CustType");
                    bc.Entity.Contact  = jp.getValue("Contact");
                    bc.Entity.Tel      = jp.getValue("Tel");
                    bc.Entity.Addr     = jp.getValue("Addr");
                    bc.Entity.Website  = jp.getValue("Website");
                    bc.Entity.Remark   = jp.getValue("Remark");
                    int r = bc.Save();
                    if (r <= 0)
                    {
                        flag = "2";
                    }
                }
                else
                {
                    Data      obj = new Data();
                    DataTable dt  = obj.ExecuteDataSet("select cnt=COUNT(*) from Base_Cust_Info where CustNo=N'" + jp.getValue("CustNo") + "' and AccID='" + user.Entity.AccID + "'").Tables[0];
                    if (int.Parse(dt.Rows[0]["cnt"].ToString()) > 0)
                    {
                        flag = "3";
                    }
                    else
                    {
                        bc.Entity.CustNo   = jp.getValue("CustNo");
                        bc.Entity.CustName = jp.getValue("CustName");
                        bc.Entity.CustType = jp.getValue("CustType");
                        bc.Entity.Contact  = jp.getValue("Contact");
                        bc.Entity.Tel      = jp.getValue("Tel");
                        bc.Entity.Addr     = jp.getValue("Addr");
                        bc.Entity.Website  = jp.getValue("Website");
                        bc.Entity.Remark   = jp.getValue("Remark");
                        bc.Entity.AccID    = user.Entity.AccID;
                        bc.Entity.Valid    = true;
                        bc.Entity.RegDate  = GetDate();
                        int r = bc.Save();
                        if (r <= 0)
                        {
                            flag = "2";
                        }
                    }
                }
            }
            catch { flag = "2"; }

            collection.Add(new JsonStringValue("type", "submit"));
            collection.Add(new JsonStringValue("flag", flag));
            collection.Add(new JsonStringValue("liststr", createList(jp.getValue("CustNameS"), int.Parse(jp.getValue("page")))));

            return(collection.ToString());
        }