protected void Page_Load(object sender, EventArgs e) { ucPager.onLoadPageIndexChaning += new _Controls_Pager.MyDele(ucPager_onLoadPageIndexChaning); if (!IsPostBack) { UserInfo user = new UserInfo(); if (Session["user"] != null) { user = (UserInfo)Session["user"]; this.txtUser.Text = ((UserInfo)Session["user"]).Name; //"单哥!HOW ARE YOU?"; } else { Response.Redirect("../login.aspx"); return; } int id = Convert.ToInt32(this.Request.QueryString["id"]); StockApplication stock = StockApplicationManager.Get(id); this.txtSAID.Text = stock.SAID.ToString(); this.txtUser.Text = stock.User.Name; this.txtTime.Value = stock.SATime; this.txtNeedCharge.Text = stock.NeedCharge.ToString(); this.txtCause.Text = stock.SACause; this.txtMark.Text = stock.SARemark; this.txtIsExamine.Text = stock.IsExamine; ucPager_onLoadPageIndexChaning(ucPager.PageIndex); } }
public static IList <StockApplication> SearchStockApplication(int said, string time, int uid) { StockApplication item = new StockApplication(); item.User.UID = uid; item.SAID = said; item.SATime = time; return(sas.Search(item)); }
public async Task <IActionResult> ReceiveStock(StockApplicationDeliverAndReceiveViewModel stockApplicationReceiveViewModel) { var result = new Result <StockApplication>(); var stockApplication = new StockApplication(); try { stockApplication = await _ablemusicContext.StockApplication .Include(sa => sa.ApplicationDetails) .Where(sa => sa.ApplicationId == stockApplicationReceiveViewModel.ApplicationId) .FirstOrDefaultAsync(); } catch (Exception ex) { result.IsSuccess = false; result.ErrorMessage = ex.Message; return(BadRequest(result)); } if (stockApplication == null) { result.IsSuccess = false; result.ErrorMessage = "stockApplication not found"; return(BadRequest(result)); } stockApplication.ProcessStatus = 5; stockApplication.RecieveAt = DateTime.UtcNow.ToNZTimezone(); foreach (var detail in stockApplication.ApplicationDetails) { foreach (var m in stockApplicationReceiveViewModel.ApplicationDetailsIdMapQty) { if (detail.DetaillsId == m.Key) { detail.ReceivedQty = m.Value; if (detail.ReceivedQty != detail.DeliveredQty) { stockApplication.IsDisputed = 1; } } } } try { await _ablemusicContext.SaveChangesAsync(); } catch (Exception ex) { result.IsSuccess = false; result.ErrorMessage = ex.Message; return(BadRequest(result)); } result.Data = stockApplication; return(Ok(result)); }
object IBaseFace.Get(int id) { StockApplication item = null; using (SqlDataReader sdr = DBHelper.ExecuteReaderProc(GET_STOCKAPPLICATION, new SqlParameter("@SAID", id))) { if (sdr.Read()) { item = new StockApplication(sdr.GetInt32(0), (UserInfo)us.GetAllUserById(sdr.GetInt32(1)), sdr.GetDateTime(2).ToString(), sdr.GetDouble(3), sdr.GetString(4), sdr.GetString(5), sdr.GetString(6)); } } return(item); }
protected void btnSubmit_Click(object sender, EventArgs e) { if (IsValid) { UserInfo user = new UserInfo(); if (Session["user"] != null) { user = (UserInfo)Session["user"]; } else { Response.Redirect("../login.aspx"); return; } if (ApplicationResources.GetItems.Count == 0) { this.ClientScript.RegisterStartupScript(GetType(), "", "<script>alert('你还没有选择资源!')</script>"); return; } else { StockApplication stock = new StockApplication(); stock.User.UID = user.UID; stock.SATime = this.txtSATime.Value.Trim(); stock.NeedCharge = Convert.ToDouble(this.txtNeedCharge.Text.Trim()); stock.SACause = this.txtSACause.Text.Trim(); stock.SARemark = this.txtMark.Text.Trim(); stock.IsExamine = "待办"; //borrow.User.UID = ((UserInfo)Session["user"]).UID/*1*/; //borrow.BATime = this.txtBorrowTime.Value.Trim(); //borrow.BAType = Convert.ToInt32(this.ddlType.SelectedValue); //borrow.ExigentGrade = this.txtExigentGrade.Text.Trim(); //borrow.BARemark = this.txtMark.Text.Trim(); //borrow.IsExamine = "未审批"; int id = StockApplicationManager.Add(stock); stock.SAID = id; Hashtable list = ApplicationResources.GetItems; foreach (int str in list.Keys) { ApplicationResourseInfo item = (ApplicationResourseInfo)list[str]; item.Stock = stock; ApplicationResourceManager.add(item); } list.Clear(); Response.Redirect("ApplyStockList.aspx"); } } }
public async Task <IActionResult> ReplyStock(int applicationId, string replyContent, DateTime applyAt, bool isApproved) { var result = new Result <StockApplication>(); var stockApplication = new StockApplication(); try { stockApplication = await _ablemusicContext.StockApplication.Where(sa => sa.ApplicationId == applicationId).FirstOrDefaultAsync(); } catch (Exception ex) { result.IsSuccess = false; result.ErrorMessage = ex.Message; return(BadRequest(result)); } if (stockApplication == null) { result.IsSuccess = false; result.ErrorMessage = "stockApplication not found"; return(BadRequest(result)); } if (stockApplication.ApplyAt.Value != applyAt) { result.IsSuccess = false; result.ErrorMessage = "This application has been updtated by other client. Please refresh page first"; return(BadRequest(result)); } stockApplication.ProcessStatus = isApproved ? (byte)2 : (byte)3; stockApplication.ReplyContent = replyContent; stockApplication.ReplyAt = DateTime.UtcNow.ToNZTimezone(); try { await _ablemusicContext.SaveChangesAsync(); } catch (Exception ex) { result.IsSuccess = false; result.ErrorMessage = ex.Message; return(BadRequest(result)); } result.Data = stockApplication; return(Ok(result)); }
public async Task <IActionResult> ApplyStock(StockApplicationViewModel stockApplicationViewModel) { var result = new Result <StockApplication>(); var stockApplication = new StockApplication { OrgId = stockApplicationViewModel.OrgId, ApplyStaffId = stockApplicationViewModel.ApplyStaffId, ApplyAt = DateTime.UtcNow.ToNZTimezone(), ProcessStatus = 1, ApplyReason = stockApplicationViewModel.ApplyReason, ReplyContent = null, IsDisputed = 0, ReplyAt = null, RecieveAt = null, DeliverAt = null, ApplicationDetails = new List <ApplicationDetails>() }; foreach (var pmq in stockApplicationViewModel.ProductIdQty) { var applicationDetails = new ApplicationDetails { ProductId = pmq.ProductId, AppliedQty = pmq.AppliedQty, DeliveredQty = null, ReceivedQty = null }; stockApplication.ApplicationDetails.Add(applicationDetails); } try { await _ablemusicContext.StockApplication.AddAsync(stockApplication); await _ablemusicContext.SaveChangesAsync(); } catch (Exception ex) { result.IsSuccess = false; result.ErrorMessage = ex.Message; return(BadRequest(result)); } result.Data = stockApplication; return(Ok(result)); }
int IBaseFace.Add(object obj) { int val = 0; if (obj is StockApplication) { StockApplication item = (StockApplication)obj; SqlParameter[] parms = new SqlParameter[] { new SqlParameter("@UID", item.User.UID), new SqlParameter("@SATime", item.SATime), new SqlParameter("@NeedCharge", item.NeedCharge), new SqlParameter("@SACause", item.SACause), new SqlParameter("@SARemark", item.SARemark), new SqlParameter("@IsExamine", item.IsExamine) }; val = DBHelper.ExecuteScalarProc(ADD_STOCKAPPLICATION, parms); } return(val); }
public async Task <IActionResult> SolveDisputeStock(int stockApplicationId) { var result = new Result <StockApplication>(); var stockApplication = new StockApplication(); try { stockApplication = await _ablemusicContext.StockApplication .Include(sa => sa.ApplicationDetails) .Where(sa => sa.ApplicationId == stockApplicationId) .FirstOrDefaultAsync(); } catch (Exception ex) { result.IsSuccess = false; result.ErrorMessage = ex.Message; return(BadRequest(result)); } if (stockApplication == null) { result.IsSuccess = false; result.ErrorMessage = "stockApplication not found"; return(BadRequest(result)); } stockApplication.IsDisputed = 0; try { await _ablemusicContext.SaveChangesAsync(); } catch (Exception ex) { result.IsSuccess = false; result.ErrorMessage = ex.Message; return(BadRequest(result)); } result.Data = stockApplication; return(Ok(result)); }
IList <StockApplication> IStockApplicationService.Search(StockApplication item) { IList <StockApplication> items = new List <StockApplication>(); SqlParameter[] parms = new SqlParameter[] { new SqlParameter("@UID", item.User.UID), new SqlParameter("@SATime", item.SATime), new SqlParameter("@NeedCharge", item.NeedCharge), new SqlParameter("@SACause", item.SACause), new SqlParameter("@SARemark", item.SARemark), new SqlParameter("@IsExamine", item.IsExamine), new SqlParameter("@SAID", item.SAID) }; using (SqlDataReader sdr = DBHelper.ExecuteReaderProc(SEARCH_STOCKAPPLICATION, parms)) { while (sdr.Read()) { StockApplication val = new StockApplication(sdr.GetInt32(0), (UserInfo)us.GetAllUserById(sdr.GetInt32(1)), sdr.GetDateTime(2).ToString(), sdr.GetDouble(3), sdr.GetString(4), sdr.GetString(5), sdr.GetString(6)); items.Add(val); } } return(items); }
/// <summary> /// 添加审批记录 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void btnSubmit_Click(object sender, EventArgs e) { Examine em = new Examine(); em.RequisitionID = Convert.ToInt32(txtApplicationId.Text); em.RequisitionType = txtType.Text; em.ExamineUID.UID = Convert.ToInt32(((UserInfo)Session["user"]).UID); em.ExamineIdea = this.txtCause.Text; em.EndTime = Convert.ToDateTime(txtTime.Value); em.IsApproved = rdoAccess.SelectedValue == "未过" ? "未过" : "通过"; //不管是否通过,都在审批记录表中添加一条审批记录 if (ExamineManager.AddExamine(em) > 0) { //判断审批是否通过, if (rdoAccess.SelectedValue == "通过") { if (txtType.Text == "会议申请") { try { MeetingApplication ma = MeetingApplicationManager.GetMeetingApplicationById(Convert.ToInt32(txtApplicationId.Text)); //获取所有与会人员, string applicationMan = ma.WithinEnlistMan; LeaveWord lw = new LeaveWord(); lw.MsgTitle = ma.MeetTitle; //会议标题 lw.MsgContent = ma.MeetContent; //会议内容 lw.MsgSendTime = Convert.ToDateTime(DateTime.Now.ToShortDateString()); //发送时间 lw.MsgState = "未读"; lw.MsgTypeId.Id = 1; //1代表会议申请 lw.SenderUser = user; //发送者 lw.MeetingBeginTime = ma.BeginTime; //开会时间 lw.MeetingAddr = ma.RoomInfo.RomeAddr; //会议地点 lw.ChargeMan = ma.Compere; //会议负责人 lw.MeetingType = ma.MeetType; //用“,”号分割与会人员 string[] array = applicationMan.Split(new char[] { ',' }); for (int i = 0; i < array.Length; i++) { int uid = UserInfoManager.GetLeaveIDByMName(array[i]); lw.ReceiverUser.UID = uid; int flag = LeaveWordManager.AddLeaveWord(lw); } //更新会议申请的状态 MeetingApplicationManager.ModifyMeetingState(Convert.ToInt32(txtApplicationId.Text), "已办"); Page.ClientScript.RegisterStartupScript(this.GetType(), "", "alert('已审核!');location.href='CheckNote.aspx'", true); } catch (Exception) { Page.ClientScript.RegisterStartupScript(this.GetType(), "", "alert('审核失败!');", true); return; } } else if (txtType.Text == "用车申请") { try { //更新用车申请状态 int flag = CarByapplyManager.UpadteByapplySate(Convert.ToInt32(txtApplicationId.Text), "已办"); Page.ClientScript.RegisterStartupScript(this.GetType(), "", "alert('已审核!');location.href='CheckNote.aspx'", true); } catch (Exception) { Page.ClientScript.RegisterStartupScript(this.GetType(), "", "alert('审核失败!');", true); return; } } } else //不通过,终结申请 { if (txtType.Text == "会议申请") { MeetingApplicationManager.ModifyMeetingState(Convert.ToInt32(txtApplicationId.Text), "终结"); } else if (txtType.Text == "用车申请") { //终结用车申请 int flag = CarByapplyManager.UpadteByapplySate(Convert.ToInt32(txtApplicationId.Text), "终结"); } Page.ClientScript.RegisterStartupScript(this.GetType(), "", "<script>alert('已终结!');window.location='Matter.aspx'</script>", true); } if (txtType.Text == "任务申请") //根据实际完成金额更新任务总体完成进度 { try { if (em.IsApproved == "通过") { TaskManager.UpdateTaskNowStatus(Convert.ToInt32(txtApplicationId.Text));//更新任务状态 //更新任务的完成比例 TaskManager.UpdateTaskFinshStatus(Convert.ToInt32(txtApplicationId.Text)); //更新申请单状态为通过 new RolePowerManager().UpdatePaddingStatus("已办", Convert.ToInt32(txtApplicationId.Text.Trim())); } else { //更新申请单状态为终结 new RolePowerManager().UpdatePaddingStatus("终结", Convert.ToInt32(txtApplicationId.Text.Trim())); } } catch (Exception) { Page.ClientScript.RegisterStartupScript(this.GetType(), "", "alert('更新任务状态失败!');", true); return; } } if (txtType.Text == "资源采购") { StockApplication stock = StockApplicationManager.Get((int)em.RequisitionID); if (em.IsApproved == "通过") { stock.IsExamine = "已办"; IList <ApplicationResourseInfo> items = ApplicationResourceManager.GetAllApplicationResource(2, stock.SAID); foreach (ApplicationResourseInfo item in items) { item.Resource.Number += item.Number; ResourceInfoManager.UpdateResourceInfo(item.Resource); } } else { stock.IsExamine = "终结"; } StockApplicationManager.Update(stock); } else if (txtType.Text == "资源借用") { BorrowApplication borrow = BorrowApplicationManager.Get((int)em.RequisitionID); if (em.IsApproved == "通过") { borrow.IsExamine = "已办"; IList <ApplicationResourseInfo> items = ApplicationResourceManager.GetAllApplicationResource(1, borrow.BAID); foreach (ApplicationResourseInfo item in items) { item.Resource.Number -= item.Number; ResourceInfoManager.UpdateResourceInfo(item.Resource); } } else { borrow.IsExamine = "终结"; } BorrowApplicationManager.Update(borrow); } Page.ClientScript.RegisterStartupScript(this.GetType(), "", "alert('已审核!');location.href='CheckNote.aspx'", true); // Response.Redirect(""); } else { Page.ClientScript.RegisterStartupScript(this.GetType(), "", "alert('审核失败!');", true); } }
public static int Update(StockApplication item) { return(sas.Update(item)); }
public static int Add(StockApplication item) { return(sas.Add(item)); }