| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684 |
- using BizCom;
- using SQLData;
- using System;
- using System.Collections.Generic;
- using System.Data;
- using System.Text;
- namespace SiteCore.Handler
- {
- public partial class sync
- {
- //店铺档案管理接口
- public void get_erp_shop()
- {
- DataStruct dStruct = GetPostStruct();
- List<string> lw = new List<string>();
- string key = GetPostString("key");
- if (key.Length > 0) lw.Add(string.Format("shopname like '%{0}%' or sname like '%{0}%' or leadername like '%{0}%'", key));
- dStruct.Order = "id desc";
- dStruct.MainWhere = string.Join(" and ", lw.ToArray());
- DataTable dt = WebCache.GetData("view_erpshop", dStruct);
- writeGridDataTableJson(dStruct.TotalCount, dt);
- }
- public void del_erp_shop()
- {
- if (UrlPostParmsCheck("eid"))
- {
- int eid = GetPostInt("eid");
- CeErpShop.Del(eid);
- returnSuccessMsg("删除成功");
- }
- }
- public void save_erp_shop()
- {
- if (UrlPostParmsCheck("shopname,user"))
- {
- int eid = GetPostInt("eid");
- CeErpShop entity = null;
- if (eid > 0) entity = CeErpShop.Get(eid);
- else entity = new CeErpShop();
- entity.UserID = GetPostInt("user");
- entity.ComName = GetPostString("ComName");
- entity.AppSecret = GetPostString("AppSecret");
- entity.ShopName = GetPostString("ShopName");
- entity.design_app_id = GetPostString("design_app_id");
- entity.design_secret = GetPostString("design_secret");
- entity.SName = GetPostString("SName");
- entity.ShopType = GetPostString("ShopType");
- entity.State = GetPostInt("State");
- entity.orderAudit = GetPostInt("orderAudit") == 0 ? false : true;
- entity.AddTime = DateTime.Now;
- entity.Summary = GetPostString("con");
- if (eid > 0) entity.Update();
- else entity.Create();
- returnSuccessMsg("保存成功!");
- }
- }
- public void tmc_erp_shop()
- {
- string sql = "select * from ce_erpshop where appsecret<>'' and taobao_user_nick<>'' and isTmc=0";
- DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
- foreach (DataRow dr in dt.Rows)
- {
- taobaoHelper.openTmc(dr["AppSecret"].ToString(), dr["taobao_user_nick"].ToString());
- }
- returnSuccessMsg("同步授权操作完成");
- }
- //供应商档案管理接口---------------------------------------------
- public void get_erp_supplier()
- {
- DataStruct dStruct = GetPostStruct();
- List<string> lw = new List<string>();
- string type = GetPostString("type");
- if (type.Length > 0) lw.Add(" SType='" + type + "'");
- string key = GetPostString("key");
- if (key.Length > 0) lw.Add(string.Format("ComName like '%{0}%' or Leader like '%{0}%'", key));
- dStruct.Order = "BSort asc";
- dStruct.MainWhere = string.Join(" and ", lw.ToArray());
- DataTable dt = WebCache.GetData("ce_erpsupplier", dStruct);
- writeGridDataTableJson(dStruct.TotalCount, dt);
- }
- public void del_erp_supplier()
- {
- if (UrlPostParmsCheck("eid"))
- {
- int eid = GetPostInt("eid");
- CeErpSupplier.Del(eid);
- LogHelper.addSupplierLog(CurrentUser.UserID, CurrentUser.UserName, "删除", "");
- returnSuccessMsg("删除成功");
- }
- }
- public void save_erp_supplier()
- {
- if (UrlPostParmsCheck("comname"))
- {
- int eid = GetPostInt("eid");
- CeErpSupplier entity = null;
- string oldCon = "";
- string newCon = "";
- if (eid > 0)
- {
- entity = CeErpSupplier.Get(eid);
- oldCon = entity.ComName + "," + entity.Leader + "," + entity.Summary + "," + entity.SType + "," + entity.Address + "," + entity.Phone;
- }
- else
- {
- entity = new CeErpSupplier();
- }
- entity.ComName = GetPostString("ComName");
- entity.Leader = GetPostString("Leader");
- entity.Summary = GetPostString("Summary");
- entity.SType = GetPostString("SType");
- entity.Address = GetPostString("Address");
- entity.XianhuoMemo = GetPostString("XianhuoMemo");
- entity.Phone = GetPostString("Phone");
- entity.BSort = GetPostInt("BSort");
- newCon = entity.ComName + "," + entity.Leader + "," + entity.Summary + "," + entity.SType + "," + entity.Address + "," + entity.Phone;
- if (eid > 0) entity.Update();
- else entity.Create();
- LogHelper.addSupplierLog(CurrentUser.UserID, CurrentUser.UserName, oldCon, newCon);
- returnSuccessMsg("保存成功!");
- }
- }
- public void upd_supplier_isaftersale()
- {
- string ison = GetString("ison");
- string sid = GetString("sid");
- if (sid.Length > 0)
- {
- int eSid = Convert.ToInt32(sid);
- string sql = "";
- sql = "update CE_ErpSupplier set IsAfterSale=" + ison + " where id=" + eSid;
- DbHelper.DbConn.ExecuteNonQuery(sql.ToString());
- returnSuccessMsg("修改成功!");
- return;
- }
- returnErrorMsg("找不到供应商");
- }
- public void upd_supplier_close()
- {
- string ison = GetString("isclose");
- string sid = GetString("sid");
- if (sid.Length > 0)
- {
- int eSid = Convert.ToInt32(sid);
- string sql = "";
- sql = "update CE_ErpSupplier set IsClose=" + ison + " where id=" + eSid;
- DbHelper.DbConn.ExecuteNonQuery(sql.ToString());
- returnSuccessMsg("修改成功!");
- return;
- }
- returnErrorMsg("找不到供应商");
- }
- //档案-设计产品 管理接口---------------------------------------------
- public void get_erp_product()
- {
- DataStruct dStruct = GetPostStruct();
- List<string> lw = new List<string>();
- string key = GetPostString("key");
- if (key.Length > 0) lw.Add(string.Format("PType like '%{0}%' or PMaterial like '%{0}%'", key));
- dStruct.Order = "id asc";
- dStruct.MainWhere = string.Join(" and ", lw.ToArray());
- DataTable dt = WebCache.GetData("ce_erpproduct", dStruct);
- writeGridDataTableJson(dStruct.TotalCount, dt);
- }
- public void del_erp_product()
- {
- if (UrlPostParmsCheck("eid"))
- {
- int eid = GetPostInt("eid");
- CeErpProduct.Del(eid);
- returnSuccessMsg("删除成功");
- }
- }
- public void save_erp_product()
- {
- if (UrlPostParmsCheck("PType"))
- {
- int eid = GetPostInt("eid");
- CeErpProduct entity = null;
- if (eid > 0) entity = CeErpProduct.Get(eid);
- else entity = new CeErpProduct();
- entity.PType = GetPostString("PType");
- entity.PName = GetPostString("PName");
- entity.PNum = GetPostString("PNum");
- entity.PMaterial = GetPostString("PMaterial");
- entity.PCraft = GetPostString("PCraft");
- entity.UpdateTime = DateTime.Now;
- entity.UpdateUserName = CurrentUser.UserName;
- if (eid > 0) entity.Update();
- else
- {
- entity.CreateTime = entity.UpdateTime;
- entity.CreateUserName = entity.UpdateUserName;
- entity.Create();
- }
- returnSuccessMsg("保存成功!");
- }
- }
- public void save_product_form_data()
- {
- if (UrlPostParmsCheck("eid"))
- {
- int eid = GetPostInt("eid");
- string json = GetPostString("json");
- CeErpProduct entity = CeErpProduct.Get(eid);
- if (entity != null)
- {
- entity.FormJson = json;
- entity.Update();
- }
- returnSuccessMsg("保存成功!");
- }
- }
- public void upd_erp_productdistribute()
- {
- if (UrlPostParmsCheck("eid"))
- {
- int eid = GetPostInt("eid");
- CeErpProduct ent = CeErpProduct.Get(eid);
- if (ent != null)
- {
- if (ent.IsAutoDistribute == 0)
- {
- ent.IsAutoDistribute = 1;
- }
- else
- {
- ent.IsAutoDistribute = 0;
- }
- ent.Update();
- returnSuccessMsg("修改成功");
- return;
- }
- returnErrorMsg("找不到记录");
- }
- }
- public void upd_erp_productwriteprice()
- {
- if (UrlPostParmsCheck("eid"))
- {
- int eid = GetPostInt("eid");
- CeErpProduct ent = CeErpProduct.Get(eid);
- if (ent != null)
- {
- if (ent.IsNeedDesignPrice == 0)
- {
- ent.IsNeedDesignPrice = 1;
- }
- else
- {
- ent.IsNeedDesignPrice = 0;
- }
- ent.Update();
- returnSuccessMsg("修改成功");
- return;
- }
- returnErrorMsg("找不到记录");
- }
- }
- public void upd_erp_product_selectalldesigner()
- {
- if (UrlPostParmsCheck("eid"))
- {
- int eid = GetPostInt("eid");
- CeErpProduct ent = CeErpProduct.Get(eid);
- if (ent != null)
- {
- if (ent.IsAutoDistribute == 0)
- {
- ent.IsAutoDistribute = 1;
- StringBuilder sql = new StringBuilder();
- sql.AppendFormat("update view_ErpUser set pemDesign=pemDesign+'{0}' where PostCode='Designer' and isOpen=1 and CHARINDEX(','+'{0}'+',',','+pemDesign+',')<=0", ent.ID);
- DbHelper.DbConn.ExecuteNonQuery(sql.ToString());
- }
- else
- {
- ent.IsAutoDistribute = 0;
- StringBuilder sql = new StringBuilder();
- sql.AppendFormat("select * from view_ErpUser where isOpen=1 and PostCode='Designer' and CHARINDEX(','+'{0}'+',',','+pemDesign+',')>0", ent.ID);
- DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
- foreach (DataRow dr in dt.Rows)
- {
- CeErpUser user = CeErpUser.Get(dr["ID"]);
- if (user != null)
- {
- string newDes = "";
- string pemDesign = user.pemDesign;
- string[] desList = pemDesign.Split(',');
- for (int i = 0; i < desList.Length; i++)
- {
- if (Convert.ToInt32(desList[i]) != ent.ID)
- {
- newDes += desList[i];
- newDes += ",";
- }
- }
- newDes = newDes.Substring(0, newDes.Length - 1);
- user.pemDesign = newDes;
- user.Update();
- }
- }
- }
- ent.Update();
- returnSuccessMsg("修改成功");
- return;
- }
- returnErrorMsg("找不到记录");
- }
- }
- //档案-产品工时 管理接口---------------------------------------------
- public void get_erp_producthour()
- {
- DataStruct dStruct = GetPostStruct();
- List<string> lw = new List<string>();
- string key = GetPostString("key");
- if (key.Length > 0) lw.Add(string.Format("PType like '%{0}%' or ProductID like '%{0}%'", key));
- dStruct.Order = "kfTime asc";
- dStruct.MainWhere = string.Join(" and ", lw.ToArray());
- DataTable dt = WebCache.GetData("view_erpproducthour", dStruct);
- writeGridDataTableJson(dStruct.TotalCount, dt);
- }
- public void del_erp_producthour()
- {
- if (UrlPostParmsCheck("eid"))
- {
- int eid = GetPostInt("eid");
- CeErpProductHour.Del(eid);
- returnSuccessMsg("删除成功");
- }
- }
- public void save_erp_producthour()
- {
- if (UrlPostParmsCheck("PType"))
- {
- int eid = GetPostInt("eid");
- CeErpProductHour entity = null;
- if (eid > 0) entity = CeErpProductHour.Get(eid);
- else entity = new CeErpProductHour();
- entity.ProductID = GetPostInt("PType");
- entity.Material = GetPostString("Material");
- entity.Craft = GetPostString("Craft");
- //entity.kfTime = GetPostInt("kfTime");
- //entity.dsjTime = GetPostInt("dsjTime");
- //entity.sjzTime = GetPostInt("sjzTime");
- //entity.xdTime = GetPostInt("xdTime");
- entity.fhTime = GetPostInt("fhTime");
- if (eid > 0) entity.Update();
- else entity.Create();
- returnSuccessMsg("保存成功!");
- }
- }
- public void upd_erp_pdhour_sort()
- {
- if (UrlPostParmsCheck("eid"))
- {
- int eid = GetPostInt("eid");
- CeErpProductHour entity = null;
- if (eid > 0) entity = CeErpProductHour.Get(eid);
- if (entity != null)
- {
- entity.kfTime = GetPostInt("sortnum");
- entity.Update();
- returnSuccessMsg("设置成功");
- return;
- }
- returnErrorMsg("未找到相关数据");
- }
- }
- //档案-供应商产品 管理接口---------------------------------------------
- public void get_erp_supplierproduct()
- {
- DataStruct dStruct = GetPostStruct();
- List<string> lw = new List<string>();
- string key = GetPostString("key");
- if (key.Length > 0) lw.Add(string.Format("ProductName like '%{0}%' or SupplierName like '%{0}%' or ProductCrafts like '%{0}%'", key));
- dStruct.Order = "id asc";
- dStruct.MainWhere = string.Join(" and ", lw.ToArray());
- dStruct.Order = "SupplierID asc,Bsort asc";
- DataTable dt = WebCache.GetData("view_erpsupplierproduct", dStruct);
- writeGridDataTableJson(dStruct.TotalCount, dt);
- }
- public void del_erp_supplierproduct()
- {
- if (UrlPostParmsCheck("eid"))
- {
- int eid = GetPostInt("eid");
- CeErpSupplierProduct.Del(eid);
- returnSuccessMsg("删除成功");
- }
- }
- public void save_erp_supplierproduct()
- {
- if (UrlPostParmsCheck("SupplierName"))
- {
- int eid = GetPostInt("eid");
- CeErpSupplierProduct entity = null;
- string oldCon = "";
- string newCon = "";
- if (eid > 0)
- {
- entity = CeErpSupplierProduct.Get(eid);
- }
- else
- {
- entity = new CeErpSupplierProduct();
- }
- entity.ProductIds = GetPostString("ProductValue");
- entity.ProductText = GetPostString("ProductText");
- entity.SupplierID = GetPostInt("SupplierName");
- entity.ProductCrafts = GetPostString("ProductCrafts");
- entity.Crafts = GetPostString("Crafts");
- entity.MinNum = GetPostInt("MinNum");
- entity.MaxNum = GetPostInt("MaxNum");
- entity.SizeL = GetPostInt("SizeL");
- entity.SizeW = GetPostInt("SizeW");
- entity.Area = GetPostString("Area");
- if (eid > 0) entity.Update();
- else entity.Create();
- //LogHelper.addSupplierLog(CurrentUser.UserID, CurrentUser.UserName, oldCon, newCon);
- returnSuccessMsg("保存成功!");
- }
- }
- //档案-开票公司信息---------------------------------------------
- public void get_erp_invoicinglist()
- {
- DataStruct dStruct = GetPostStruct();
- List<string> lw = new List<string>();
- string key = GetPostString("key");
- if (key.Length > 0) lw.Add(string.Format("ComName like '%{0}%' or tax like '%{0}%'", key));
- dStruct.Order = "id desc";
- dStruct.MainWhere = string.Join(" and ", lw.ToArray());
- DataTable dt = WebCache.GetData("ce_erpinvoicinginfo", dStruct);
- writeGridDataTableJson(dStruct.TotalCount, dt);
- }
- public void del_erp_invoicing()
- {
- if (UrlPostParmsCheck("eid"))
- {
- int eid = GetPostInt("eid");
- CeErpInvoicingInfo.Del(eid);
- returnSuccessMsg("删除成功");
- }
- }
- public void save_erp_invoicinginfo()
- {
- if (UrlPostParmsCheck("ComName,tax"))
- {
- int eid = GetPostInt("eid");
- CeErpInvoicingInfo entity = null;
- if (eid > 0) entity = CeErpInvoicingInfo.Get(eid);
- else entity = new CeErpInvoicingInfo();
- entity.ComName = GetPostString("ComName");
- entity.CName = GetPostString("CName");
- entity.Tax = GetPostString("Tax");
- entity.taxrate = GetPostString("taxrate");
- entity.Address = GetPostString("Address");
- entity.Phone = GetPostString("Phone");
- entity.Bank = GetPostString("Bank");
- entity.BankAcc = GetPostString("BankAcc");
- entity.BillKey = GetPostString("BillKey");
- entity.legal = GetPostString("legal");
- entity.LimitPrice = Convert.ToDouble(GetPostString("LimitPrice"));
- if (eid > 0) entity.Update();
- else entity.Create();
- returnSuccessMsg("保存成功!");
- }
- }
- //获取买家客户信息
- public void get_erp_customerinfo()
- {
- DataStruct dStruct = GetPostStruct();
- List<string> lw = new List<string>();
- string key = GetPostString("key");
- if (key.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%' or phone like '%{0}%'", key));
- dStruct.Order = "id desc";
- dStruct.MainWhere = string.Join(" and ", lw.ToArray());
- DataTable dt = WebCache.GetData("CE_ErpCustomer", dStruct);
- writeGridDataTableJson(dStruct.TotalCount, dt);
- }
- //行业
- public void get_erp_professionlist()
- {
- DataStruct dStruct = GetPostStruct();
- List<string> lw = new List<string>();
- string key = GetPostString("key");
- if (key.Length > 0) lw.Add(string.Format("Name like '%{0}%'", key));
- dStruct.Order = "id desc";
- dStruct.MainWhere = string.Join(" and ", lw.ToArray());
- DataTable dt = WebCache.GetData("CE_ErpProfession", dStruct);
- con.Response.Write(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
- }
- public void save_erp_profession()
- {
- if (UrlPostParmsCheck("profession"))
- {
- int eid = GetPostInt("eid");
- CeErpProfession entity = null;
- if (eid > 0) entity = CeErpProfession.Get(eid);
- else entity = new CeErpProfession();
- entity.Name = GetPostString("profession");
- string pid = GetPostString("pid");
- if (pid.Length > 0)
- {
- entity.PID = Convert.ToInt32(pid);
- }
- else
- {
- entity.PID = -1;
- }
- if (eid > 0) entity.Update();
- else
- {
- entity.AddTime = DateTime.Now;
- entity.Create();
- }
- returnSuccessMsg("保存成功!");
- }
- }
- public void del_erp_profession()
- {
- if (UrlPostParmsCheck("eid"))
- {
- int eid = GetPostInt("eid");
- CeErpProfession.Del(eid);
- returnSuccessMsg("删除成功");
- }
- }
- //设计费列表
- public void get_erp_prdouctPrice()
- {
- DataStruct dStruct = GetPostStruct();
- List<string> lw = new List<string>();
- string key = GetPostString("key");
- if (key.Length > 0) lw.Add(string.Format("pType like '%{0}%' or tax like '%{0}%'", key));
- dStruct.Order = "pType desc";
- dStruct.MainWhere = string.Join(" and ", lw.ToArray());
- DataTable dt = WebCache.GetData("CE_ErpProductPrice", dStruct);
- writeGridDataTableJson(dStruct.TotalCount, dt);
- }
- public void save_erp_productPrice()
- {
- if (UrlPostParmsCheck("PType"))
- {
- int eid = GetPostInt("eid");
- int pid = GetPostInt("pType");
- CeErpProductPrice entity = null;
- if (eid > 0) entity = CeErpProductPrice.Get(eid);
- else entity = new CeErpProductPrice();
- CeErpProduct entitys = CeErpProduct.Get(pid);
- entity.pClass = GetPostInt("pClass");
- //entity.pClassText = ProductCategory.getText(entity.pClass);
- entity.pType = entitys.ID;
- entity.pTypeText = entitys.PType;
- entity.ws = GetPostDouble("ws");
- entity.pMaterial = GetPostString("pMaterial");
- entity.modifyPrice = GetPostDouble("modifyPrice");
- entity.designPrice = GetPostDouble("designPrice");
- if (eid > 0) entity.Update();
- else entity.Create();
- returnSuccessMsg("保存成功!");
- }
- }
- public void del_erp_productPrice()
- {
- if (UrlPostParmsCheck("eid"))
- {
- int eid = GetPostInt("eid");
- CeErpProductPrice.Del(eid);
- returnSuccessMsg("删除成功");
- }
- }
- //快递管理
- public void get_erp_maillist()
- {
- DataStruct dStruct = GetPostStruct();
- List<string> lw = new List<string>();
- string key = GetPostString("key");
- if (key.Length > 0) lw.Add(string.Format("Name like '%{0}%'", key));
- dStruct.Order = "id desc";
- dStruct.MainWhere = string.Join(" and ", lw.ToArray());
- DataTable dt = WebCache.GetData("CE_ErpMailInfo", dStruct);
- con.Response.Write(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
- }
- public void save_erp_mailinfo()
- {
- if (UrlPostParmsCheck("name"))
- {
- int eid = GetPostInt("eid");
- CeErpMailInfo entity = null;
- if (eid > 0) entity = CeErpMailInfo.Get(eid);
- else entity = new CeErpMailInfo();
- entity.name = GetPostString("name");
- entity.code = GetPostString("code");
- entity.cpCode = GetPostString("cpcode");
- if (eid > 0) entity.Update();
- else
- {
- entity.addTime = DateTime.Now;
- entity.Create();
- }
- returnSuccessMsg("保存成功!");
- }
- }
- public void del_erp_mailinfo()
- {
- if (UrlPostParmsCheck("eid"))
- {
- int eid = GetPostInt("eid");
- CeErpMailInfo.Del(eid);
- returnSuccessMsg("删除成功");
- }
- }
- public void upd_mail_auth()
- {
- int aid = GetPostInt("aid");
- int tag = GetPostInt("tag");
- CeErpMailInfo entity = null;
- if (aid > 0) entity = CeErpMailInfo.Get(aid);
- if (entity != null)
- {
- entity.isAuth = tag;
- entity.Update();
- returnSuccessMsg("修改成功");
- return;
- }
- returnErrorMsg("没有找到数据");
- }
- }
- }
|