/// <summary> /// get useless product /// <summary> /// <param name=out emsg>return error message</param> ///<returns>details of all productlist</returns> public BindingCollection <modProductList> GetUselessProduct(string accname, out string emsg) { try { BindingCollection <modProductList> modellist = new BindingCollection <modProductList>(); //Execute a query to read the categories int inoutdays = 30; dalSysParameters dalpara = new dalSysParameters(); modSysParameters modpara = dalpara.GetItem("PRODUCT_CLEAR_DAYS", out emsg); if (!string.IsNullOrEmpty(modpara.ParaValue) && Convert.ToInt32(modpara.ParaValue) >= inoutdays) { inoutdays = Convert.ToInt32(modpara.ParaValue); } dalAccPeriodList dalp = new dalAccPeriodList(); modAccPeriodList modp = dalp.GetItem(accname, out emsg); string sql = string.Format(@"select product_id,product_name,product_type,barcode,size_flag,specify,brand,unit_no,remark,min_qty,max_qty,update_user,update_time from product_list a where status<>7 and update_time<=getdate()-7 and not exists(select '#' from acc_product_inout where acc_name='{0}' and product_id=a.product_id) and not exists(select '#' from warehouse_product_inout where product_id=a.product_id and (inout_date>=getdate()-{1} or inout_date>='{2}')) order by update_time" , accname, inoutdays, modp.StartDate); using (SqlDataReader rdr = SqlHelper.ExecuteReader(sql)) { while (rdr.Read()) { modProductList model = new modProductList(); model.ProductId = dalUtility.ConvertToString(rdr["product_id"]); model.ProductName = dalUtility.ConvertToString(rdr["product_name"]); model.ProductType = dalUtility.ConvertToString(rdr["product_type"]); model.Barcode = dalUtility.ConvertToString(rdr["barcode"]); model.SizeFlag = dalUtility.ConvertToInt(rdr["size_flag"]); model.Specify = dalUtility.ConvertToString(rdr["specify"]); model.Brand = dalUtility.ConvertToString(rdr["brand"]); model.UnitNo = dalUtility.ConvertToString(rdr["unit_no"]); model.Remark = dalUtility.ConvertToString(rdr["remark"]); model.MinQty = dalUtility.ConvertToDecimal(rdr["min_qty"]); model.MaxQty = dalUtility.ConvertToDecimal(rdr["max_qty"]); model.UpdateUser = dalUtility.ConvertToString(rdr["update_user"]); model.UpdateTime = dalUtility.ConvertToDateTime(rdr["update_time"]); modellist.Add(model); } } emsg = null; return(modellist); } catch (Exception ex) { emsg = dalUtility.ErrorMessage(ex.Message); return(null); } }
/// <summary> /// delete a customerlog /// <summary> /// <param name=id>id</param> /// <param name=out emsg>return error message</param> /// <returns>true/false</returns> public bool Delete(int id, out string emsg) { try { modCustomerLog mod = GetItem(id, out emsg); if (mod == null) { emsg = null; return(true); } dalUserList dalu = new dalUserList(); DateTime svrtime = dalu.GetServerTime(out emsg); TimeSpan ts1 = new TimeSpan(svrtime.Ticks); TimeSpan ts2 = new TimeSpan(DateTime.Parse(mod.ToTime).Ticks); TimeSpan ts = ts1.Subtract(ts2).Duration(); if (ts.Days < 0) { emsg = "您不能删除未来的工作日志!"; return(false); } dalSysParameters dalp = new dalSysParameters(); int delaydays = Convert.ToInt32(dalp.GetParaValue("CUSTOMER_LOG_DELAY_DAYS")); if (ts.Days >= delaydays) { emsg = "您提交的日期不能超过" + delaydays.ToString() + "天"; return(false); } string sql = string.Format("delete customer_log where id={0} ", id); int i = SqlHelper.ExecuteNonQuery(sql); if (i > 0) { emsg = null; return(true); } else { emsg = "Unknown error when ExecuteNonQuery!"; return(false); } } catch (Exception ex) { emsg = dalUtility.ErrorMessage(ex.Message); return(false); } }
/// <summary> /// update a customerlog /// <summary> /// <param name=id>id</param> /// <param name=mod>model object of customerlog</param> /// <param name=out emsg>return error message</param> /// <returns>true/false</returns> public bool Update(int id, modCustomerLog mod, out string emsg) { try { dalUserList dalu = new dalUserList(); DateTime svrtime = dalu.GetServerTime(out emsg); TimeSpan ts1 = new TimeSpan(svrtime.Ticks); TimeSpan ts2 = new TimeSpan(DateTime.Parse(mod.ToTime).Ticks); TimeSpan ts = ts1.Subtract(ts2).Duration(); if (ts.Days < 0) { emsg = "您不能更新未来的工作日志!"; return(false); } dalSysParameters dalp = new dalSysParameters(); int delaydays = Convert.ToInt32(dalp.GetParaValue("CUSTOMER_LOG_DELAY_DAYS")); if (ts.Days >= delaydays) { emsg = "你提交的日期不能超过" + delaydays.ToString() + "天"; return(false); } string sql = string.Format("update customer_log set cust_id='{0}',cust_name='{1}',action_code='{2}',action_type='{3}',action_man='{4}',form_id='{5}',action_subject='{6}',action_content='{7}',object_name='{8}',venue='{9}',from_time='{10}',to_time='{11}',scores={12},ad_flag={13},update_user='******',update_time=getdate() where id={15}", mod.CustId, mod.CustName, mod.ActionCode, mod.ActionType, mod.ActionMan, mod.FormId, mod.ActionSubject, mod.ActionContent, mod.ObjectName, mod.Venue, mod.FromTime, mod.ToTime, mod.Scores, mod.AdFlag, mod.UpdateUser, id); int i = SqlHelper.ExecuteNonQuery(sql); if (i > 0) { emsg = null; return(true); } else { emsg = "Unknown error when ExecuteNonQuery!"; return(false); } } catch (Exception ex) { emsg = dalUtility.ErrorMessage(ex.Message); return(false); } }
/// <summary> /// insert a crmactionschedule /// <summary> /// <param name=mod>model object of crmactionschedule</param> /// <param name=out emsg>return error message</param> /// <returns>true/false</returns> public bool Insert(modCrmActionSchedule mod, out string emsg) { try { dalUserList dalu = new dalUserList(); DateTime svrtime = dalu.GetServerTime(out emsg); TimeSpan ts1 = new TimeSpan(svrtime.Ticks); TimeSpan ts2 = new TimeSpan(mod.ActionDate.Ticks); TimeSpan ts = ts2.Subtract(ts1).Duration(); if (ts.Days < 0) { emsg = "您不能新增过去的工作计划!"; return(false); } dalSysParameters dalp = new dalSysParameters(); int aheaddays = Convert.ToInt32(dalp.GetParaValue("ACTION_SCHEDULE_AHEAD_DAYS")); if (ts.Days > aheaddays) { emsg = "您不能提交" + aheaddays.ToString() + "天后的工作计划"; return(false); } string sql = string.Format("insert into crm_action_schedule(action_man,action_date,action_content,status,status_desc,update_user,update_time)values('{0}','{1}','{2}','{3}','{4}','{5}',getdate())", mod.ActionMan, mod.ActionDate, mod.ActionContent, mod.Status, mod.StatusDesc, mod.UpdateUser); int i = SqlHelper.ExecuteNonQuery(sql); if (i > 0) { emsg = null; return(true); } else { emsg = "Unknown error when ExecuteNonQuery!"; return(false); } } catch (Exception ex) { emsg = dalUtility.ErrorMessage(ex.Message); return(false); } }
/// <summary> /// get all vendororderlist /// <summary> /// <param name=incfinished>incfinished</param> /// <param name=custid>custid</param> /// <param name=vendorname>vendorname</param> /// <param name=vendororderno>vendororderno</param> /// <param name=formdate>formdate</param> /// <param name=out emsg>return error message</param> ///<returns>details of all vendororderlist</returns> public BindingCollection <modVendorOrderList> GetIList(bool incfinished, string vendorname, string vendororderno, string salesmanlist, string fromdate, string todate, out string emsg) { try { BindingCollection <modVendorOrderList> modellist = new BindingCollection <modVendorOrderList>(); //Execute a query to read the categories string vendornamewhere = string.Empty; if (vendorname != "ALL" && !string.IsNullOrEmpty(vendorname)) { vendornamewhere = "and vendor_name like '%" + vendorname + "%' "; } string salesmanwhere = string.Empty; if (!string.IsNullOrEmpty(salesmanlist) && salesmanlist.CompareTo("ALL") != 0) { salesmanwhere = "and purchase_man in ('" + salesmanlist.Replace(",", "','") + "') "; } string formdatewhere = string.Empty; if (!string.IsNullOrEmpty(fromdate)) { formdatewhere = "and form_date >= '" + Convert.ToDateTime(fromdate) + "' "; } if (!string.IsNullOrEmpty(todate)) { formdatewhere += "and form_date <= '" + Convert.ToDateTime(todate) + "' "; } dalSysParameters dalpara = new dalSysParameters(); modSysParameters modpara = dalpara.GetItem("ORDER_FINISHED_RATIO", out emsg); decimal ratio_f = Convert.ToDecimal(modpara.ParaValue); string sql = "select id,vendor_name,vendor_order_no,form_date,require_date,pay_method,purchase_man,product_id,product_name,specify,size,unit_no,qty,price,remark,currency,update_user,update_time " + "from vendor_order_list where 1=1 " + vendornamewhere + salesmanwhere + formdatewhere + "order by id desc"; using (SqlDataReader rdr = SqlHelper.ExecuteReader(sql)) { while (rdr.Read()) { modVendorOrderList model = new modVendorOrderList(); model.Id = dalUtility.ConvertToInt(rdr["id"]); model.VendorName = dalUtility.ConvertToString(rdr["vendor_name"]); model.VendorOrderNo = dalUtility.ConvertToString(rdr["vendor_order_no"]); model.FormDate = dalUtility.ConvertToDateTime(rdr["form_date"]); model.RequireDate = dalUtility.ConvertToDateTime(rdr["require_date"]); model.PayMethod = dalUtility.ConvertToString(rdr["pay_method"]); model.PurchaseMan = dalUtility.ConvertToString(rdr["purchase_man"]); model.ProductId = dalUtility.ConvertToString(rdr["product_id"]); model.ProductName = dalUtility.ConvertToString(rdr["product_name"]); model.Specify = dalUtility.ConvertToString(rdr["specify"]); model.Size = dalUtility.ConvertToDecimal(rdr["size"]); model.UnitNo = dalUtility.ConvertToString(rdr["unit_no"]); model.Qty = dalUtility.ConvertToDecimal(rdr["qty"]); model.Price = dalUtility.ConvertToDecimal(rdr["price"]); model.SumMny = model.Qty * model.Price; model.ReceivedQty = GetReceivedQty(model.VendorName, model.VendorOrderNo, model.ProductId); model.Differ = model.Qty - model.ReceivedQty; model.Remark = dalUtility.ConvertToString(rdr["remark"]); model.Currency = dalUtility.ConvertToString(rdr["currency"]); model.UpdateUser = dalUtility.ConvertToString(rdr["update_user"]); model.UpdateTime = dalUtility.ConvertToDateTime(rdr["update_time"]); if (incfinished || model.ReceivedQty < model.Qty * ratio_f) { modellist.Add(model); } } } emsg = null; return(modellist); } catch (Exception ex) { emsg = dalUtility.ErrorMessage(ex.Message); return(null); } }