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 lw = new List(); 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 lw = new List(); 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 lw = new List(); 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 lw = new List(); 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 lw = new List(); 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 lw = new List(); 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 lw = new List(); 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 lw = new List(); 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 lw = new List(); 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 lw = new List(); 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("没有找到数据"); } } }