/// <summary> /// 确认提交 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void btnOK_Click(object sender, EventArgs e) { bool isEdit = false; int did = 0; Model.FatherOrder modelFather = new Model.FatherOrder(); if (int.TryParse(Request.Params["fid"], out fid)) { modelFather = bllFathrt.GetModel(fid); did = modelFather.Id; isEdit = true; } else { DataSet ds = bllFathrt.GetList("CustomerId=" + ddlCustomer.SelectedValue + " and AddTime>Convert(datetime,'" + DateTime.Now.ToString("yyyy-MM-dd") + " 00:00:00" + "') and Convert(datetime,AddTime) <= Convert(datetime,'" + DateTime.Now.ToString("yyyy-MM-dd") + " 23:59:59" + "')"); if (ds.Tables[0].Rows.Count > 0) { modelFather = bllFathrt.GetModel(int.Parse(ds.Tables[0].Rows[0]["Id"].ToString())); isEdit = true; } else { modelFather.AddTime = DateTime.Now; modelFather.NumId = SetFathrtNumID(); modelFather.MoneyState = 0; } } if (!string.IsNullOrEmpty(Request.Form["ddlAddress"])) { modelFather.AddressId = int.Parse(Request.Form["ddlAddress"]); } modelFather.CustomerId = int.Parse(ddlCustomer.SelectedValue); modelFather.StateInfo = 10022; modelFather.WorkersId = int.Parse(Session["AdminId"].ToString()); modelFather.Remark = txtExplain.Text; if (!isEdit) { did = bllFathrt.Add(modelFather); } else { bllFathrt.Update(modelFather); } AddDistribution(did); JsMessage("公司订单添加成功", 2000, "true", "index.aspx"); }
/// <summary> /// 添加公司订单 /// </summary> /// <returns></returns> int AddFathrtNum() { Model.Customer modelCustomer = bllCustomer.GetModel(int.Parse(ddlCustomer.SelectedValue)); int fathrtId; //直接客户当天订单好 int customerId; //获取直接客户编号 if (modelCustomer.ParentId == 0) //直接客户下单 { customerId = modelCustomer.Id; } else//非直接客户下单 { customerId = modelCustomer.ParentId; } DataSet ds = bllFathrt.GetList("CustomerId=" + customerId + " and AddTime>Convert(datetime,'" + DateTime.Now.ToString("yyyy-MM-dd") + " 00:00:00" + "') and Convert(datetime,AddTime) <= Convert(datetime,'" + DateTime.Now.ToString("yyyy-MM-dd") + " 23:59:59" + "')"); //" and O_AddTime " if (ds.Tables[0].Rows.Count > 0)//已经存在订单了 { fathrtId = int.Parse(ds.Tables[0].Rows[0]["Id"].ToString()); } else//不存在订单 { Model.FatherOrder modelFather = new Model.FatherOrder(); modelFather.NumId = SetFathrtNumID(); if (!string.IsNullOrEmpty(ddlAddress.SelectedValue)) { modelFather.AddressId = int.Parse(ddlAddress.SelectedValue); } modelFather.AddTime = DateTime.Now; modelFather.CustomerId = customerId; modelFather.StateInfo = 10022; modelFather.WorkersId = int.Parse(Session["AdminId"].ToString()); fathrtId = bllFathrt.Add(modelFather); } return(fathrtId); }