private void LastUpdate(int id) { CAI_OrderInHousesService ordersSer = new CAI_OrderInHousesService(); List <CAI_OrderInHouses> orders = ordersSer.GetListArray(" 1=1 and CAI_OrderInHouses.id=1"); CAI_OrderChecksService ordersSer111 = new CAI_OrderChecksService(); List <CAI_OrderChecks> orders1111 = ordersSer111.GetListArray(" 1=1 and CAI_OrderChecks.CheckId=" + id); CAI_OrderCheckService mainSer = new CAI_OrderCheckService(); CAI_OrderCheck pp = mainSer.GetModel(id); DBHelp.ExeCommand(string.Format(@" update CAI_OrderInHouse SET ChcEkProNo='{0}',pono='{1}',poname='{2}' where id=1; update CAI_OrderOutHouse set pono='{1}',poname='{2}' where ChcEkProNo='20120000'; update CAI_OrderCheck set status='通过' where id={3} ;update tb_EForm set state='通过',e_LastTime=getdate() where allE_id={3} and proId=21;", pp.ProNo, orders1111[0].PONo, orders1111[0].POName, id)); using (SqlConnection conn = DBHelp.getConn()) { conn.Open(); SqlTransaction tan = conn.BeginTransaction(); SqlCommand objCommand = conn.CreateCommand(); objCommand.Transaction = tan; CAI_POCaiService CaiSer = new CAI_POCaiService(); try { objCommand.Parameters.Clear(); foreach (var caiIn in orders) { var check = orders1111.Single(t => t.CheckGoodId == caiIn.GooId); string sql = string.Format(" update CAI_OrderInHouses set OrderCheckIds={1} where ids={0}", caiIn.Ids, check.Ids); objCommand.CommandText = sql; objCommand.ExecuteNonQuery(); } tan.Commit(); } catch (Exception) { tan.Rollback(); } } }
private int AddCai() { CAI_OrderInHousesService ordersSer = new CAI_OrderInHousesService(); orders_CaiIn = ordersSer.GetListArray(" 1=1 and CAI_OrderInHouses.id=1"); //采购单 CAI_POOrder order = new CAI_POOrder(); order.AppName = 1; order.CaiGou = "admin"; order.AE = ""; order.GuestName = ""; order.GuestNo = ""; order.INSIDE = ""; order.PODate = Convert.ToDateTime("2012-06-19"); order.POName = "库存初始化"; order.POPayStype = "1"; order.POTotal = Convert.ToDecimal(628650.72000); order.PONo = ""; order.BusType = "1"; order.CG_ProNo = ""; order.cRemark = ""; List <CAI_POOrders> POOrders = new List <CAI_POOrders>(); foreach (var m in orders_CaiIn) { CAI_POOrders cai = new CAI_POOrders(); cai.InvName = m.GoodName; cai.Num = m.GoodNum; cai.CostPrice = m.GoodPrice; cai.OtherCost = 0; cai.ToTime = Convert.ToDateTime("2012-06-26 00:00:00.000"); cai.Profit = 0; cai.GoodId = m.GooId; cai.CG_POOrdersId = 0; POOrders.Add(cai); } List <CAI_POCai> caiOrders = new List <CAI_POCai>(); foreach (var m in orders_CaiIn) { CAI_POCai cai = new CAI_POCai(); cai.Supplier = "本部门(含税)"; cai.SupperPrice = m.GoodPrice; cai.UpdateUser = "******"; cai.Idea = ""; cai.Num = m.GoodNum; cai.FinPrice1 = m.GoodPrice; cai.GoodId = m.GooId; cai.cbifDefault1 = true; cai.lastSupplier = "本部门(含税)"; cai.IsHanShui = true; cai.LastTruePrice = m.GoodPrice; caiOrders.Add(cai); } tb_EForm eform = new tb_EForm(); eform.appPer = 1; eform.appTime = DateTime.Now; eform.createPer = 1; eform.createTime = DateTime.Now; eform.proId = 20; eform.state = "通过"; eform.toPer = 0; eform.toProsId = 0; CAI_POOrderService POOrderSer = new CAI_POOrderService(); int MainId = 0; return(POOrderSer.addTran(order, eform, POOrders, caiOrders, out MainId, false)); }
protected void Page_Load(object sender, EventArgs e) { if (!base.IsPostBack) { //请假单子 Session["Orders"] = null; lbtnAddFiles.Visible = false; gvList.Columns[0].Visible = false; gvList.Columns[6].Visible = false; gvList.Columns[10].Visible = false; Dal.BaseInfo.TB_HouseInfoService houseSer = new VAN_OA.Dal.BaseInfo.TB_HouseInfoService(); List <Model.BaseInfo.TB_HouseInfo> houseList = houseSer.GetListArray(""); ddlHouse.DataSource = houseList; ddlHouse.DataBind(); ddlHouse.DataTextField = "houseName"; ddlHouse.DataValueField = "id"; if (base.Request["ProId"] != null) { //加载基本数据 VAN_OA.Model.User use = Session["userInfo"] as VAN_OA.Model.User; txtName.Text = use.LoginName; tb_EFormService eformSer = new tb_EFormService(); if (Request["allE_id"] == null)//单据增加 { txtRuTime.Text = DateTime.Now.ToString(); //权限1(销售) lbtnAddFiles.Visible = true; gvList.Columns[0].Visible = true; gvList.Columns[6].Visible = true; gvList.Columns[7].Visible = false; gvList.Columns[10].Visible = true; gvList.Columns[11].Visible = false; //加载初始数据 List <CAI_OrderInHouses> orders = new List <CAI_OrderInHouses>(); Session["Orders"] = orders; ViewState["OrdersCount"] = orders.Count; gvList.DataSource = orders; gvList.DataBind(); txtRuTime.Text = DateTime.Now.ToString(); //检查自己是否在请假单中流程设置中,来确定自己下一个审批人 lblResult.Visible = false; lblYiJian.Visible = false; ddlResult.Visible = false; txtResultRemark.Visible = false; if (eformSer.ifHasNodes(Convert.ToInt32(Request["ProId"]))) { //获取审批人 int pro_IDs = 0; int ids = 0; List <A_Role_User> roleUserList = eformSer.getFristNodeUsers(Convert.ToInt32(Session["currentUserId"].ToString()), Convert.ToInt32(Request["ProId"]), out ids); ViewState["ids"] = ids; if (roleUserList != null) { ddlPers.DataSource = roleUserList; ddlPers.DataBind(); ddlPers.DataTextField = "UserName"; ddlPers.DataValueField = "UserId"; } else { lblPer.Visible = false; ddlPers.Visible = false; } } else { lblPer.Visible = false; ddlPers.Visible = false; } } else//单据审批 { ViewState["POOrdersIds"] = ""; //加载已经审批的数据 tb_EFormsService eformsSer = new tb_EFormsService(); List <VAN_OA.Model.EFrom.tb_EForms> eforms = eformsSer.GetListArray(string.Format(" e_Id in (select id from tb_EForm where proId={0} and allE_id={1})", Convert.ToInt32(Request["ProId"]), Convert.ToInt32(Request["allE_id"]))); if (eforms.Count > 0) { string mess = @"<table cellpadding='0' cellspacing='0' width='100%' bordercolorlight='#999999' bordercolordark='#FFFFFF' border='1' ><tr><td colspan='6' style=' height:20px; background-color:#336699; color:White;'>流程图</td></tr>"; for (int i = 0; i < eforms.Count; i++) { string per = ""; if (eforms[i].consignor != null && eforms[i].consignor != 0) { per = eforms[i].Consignor_Name + "(委托人:" + eforms[i].Audper_Name + ")"; } else { per = eforms[i].Audper_Name; } mess += string.Format("<tr><td align='center'>第{0}步</td><td>序号{0}:{1}</td><td><span style='color:red;'>{2}</span>[<span style='color:blue;'>{3} {4}</span>]<br/>意见:{5}</td></tr>", i + 1, eforms[i].RoleName , per, eforms[i].resultState, eforms[i].doTime, eforms[i].idea); } mess += "</table>"; lblMess.Text = mess; } ViewState["EformsCount"] = eforms.Count; #region 加载 请假单数据 CAI_OrderInHouseService mainSer = new CAI_OrderInHouseService(); CAI_OrderInHouse pp = mainSer.GetModel(Convert.ToInt32(Request["allE_id"])); txtName.Text = pp.CreateName; txtChcekProNo.Text = pp.ChcekProNo; txtPOName.Text = pp.POName; txtPONo.Text = pp.PONo; txtRemark.Text = pp.Remark; txtRuTime.Text = pp.RuTime.ToString(); txtSupplier.Text = pp.Supplier; ddlHouse.Text = pp.HouseID.ToString(); txtCaiGou.Text = pp.DoPer; txtFPNo.Text = pp.FPNo; if (pp.ProNo != null) { lblProNo.Text = pp.ProNo; } CAI_OrderInHousesService ordersSer = new CAI_OrderInHousesService(); List <CAI_OrderInHouses> orders = ordersSer.GetListArray(" 1=1 and CAI_OrderInHouses.id=" + Request["allE_id"]); Session["Orders"] = orders; ViewState["OrdersCount"] = orders.Count; gvList.DataSource = orders; gvList.DataBind(); #endregion //判断单据是否已经结束 if (eformSer.ifFinish(Convert.ToInt32(Request["ProId"]), Convert.ToInt32(Request["allE_id"]))) { btnSub.Visible = false; lblPer.Visible = false; ddlPers.Visible = false; lblResult.Visible = false; lblYiJian.Visible = false; ddlResult.Visible = false; txtResultRemark.Visible = false; setEnable(false); } else { //是否为审核人 if (eformSer.ifAudiPer(Convert.ToInt32(Session["currentUserId"]), Convert.ToInt32(Request["ProId"]), Convert.ToInt32(Request["allE_id"]))) { if (eformSer.ifLastNode(Convert.ToInt32(Request["ProId"]), Convert.ToInt32(Request["allE_id"]))) { lblPer.Visible = false; ddlPers.Visible = false; } else { int ids = 0; List <A_Role_User> roleUserList = eformSer.getUserToAdu(Convert.ToInt32(Request["ProId"]), Convert.ToInt32(Request["allE_id"]), out ids); ViewState["ids"] = ids; if (roleUserList != null) { ddlPers.DataSource = roleUserList; ddlPers.DataBind(); ddlPers.DataTextField = "UserName"; ddlPers.DataValueField = "UserId"; } } setEnable(eformSer.ifEdit(Convert.ToInt32(Request["ProId"]), Convert.ToInt32(Request["allE_id"]))); } else { //是否为代理人 if (eformSer.ifAudiPerByUserName(Convert.ToInt32(Session["currentUserId"]), Convert.ToInt32(Request["ProId"]), Convert.ToInt32(Request["allE_id"]))) { ViewState["ifConsignor"] = true; if (eformSer.ifLastNode(Convert.ToInt32(Request["ProId"]), Convert.ToInt32(Request["allE_id"]))) { lblPer.Visible = false; ddlPers.Visible = false; } else { int ids = 0; List <A_Role_User> roleUserList = eformSer.getUserToAdu(Convert.ToInt32(Request["ProId"]), Convert.ToInt32(Request["allE_id"]), out ids); ViewState["ids"] = ids; if (roleUserList != null) { ddlPers.DataSource = roleUserList; ddlPers.DataBind(); ddlPers.DataTextField = "UserName"; ddlPers.DataValueField = "UserId"; } } setEnable(eformSer.ifEdit(Convert.ToInt32(Request["ProId"]), Convert.ToInt32(Request["allE_id"]))); } else { btnSub.Visible = false; lblPer.Visible = false; ddlPers.Visible = false; lblResult.Visible = false; lblYiJian.Visible = false; ddlResult.Visible = false; txtResultRemark.Visible = false; setEnable(false); } } } } } } }