protected void Submit_Click(object sender, EventArgs e) { #region int temp = 0; decimal tempde = 0.0M; int Index = 0; int.TryParse(tb_EIndex.Value, out Index); for (int i = 0; i < Index; i++) { if (!string.IsNullOrEmpty(Request.Form["code" + i + ""])&&!string.IsNullOrEmpty(Request.Form["name"+i])) { if (string.IsNullOrEmpty(Request.Form["num" + i + ""])) { LabMS.Common.JShelper.JSAlert(Page, "err", "����������������Ϊ��!"); return; } else { if (!int.TryParse(Request.Form["num" + i + ""], out temp)) { LabMS.Common.JShelper.JSAlert(Page, "err", "��������������������Ϊ����!"); return; } } if (string.IsNullOrEmpty(Request.Form["unitprice" + i])) { LabMS.Common.JShelper.JSAlert(Page, "err", "�����������۲���Ϊ��!"); return; } else { if (!decimal.TryParse(Request.Form["unitprice" + i], out tempde)) { LabMS.Common.JShelper.JSAlert(this, "err", "���������ĵ���ֻ��Ϊ����!"); return; } } if (string.IsNullOrEmpty(Request.Form["model" + i])) { LabMS.Common.JShelper.JSAlert(this, "err", "�����������ͺŲ���Ϊ��"); return; } } } #endregion LabMS.BLL.ProjectApp App = new LabMS.BLL.ProjectApp(); LabMS.Model.ProjectApp model = new LabMS.Model.ProjectApp(); model = App.GetModel(QueryString); try { model.App_ApplyFinancing = Convert.ToInt32(tb_ApplyFinancing.Text); } catch { LabMS.Common.JShelper.JSAlert(this, "�������Ϊ����", "ȷ������Ľ��Ϊ����"); return; } #region ������ model.App_InCharge = tb_InCharge.Text; model.App_Phone = tb_Phone.Text; model.App_Code = tb_Name.Text; model.App_ProjectCode = tb_Code.Text; int Temp=0; if (int.TryParse(ddl_Lab.SelectedValue, out Temp)) { if (Temp > 0) { model.LabID = Temp; } } model.App_Location = tb_Loction.Text; model.App_Necessity = tb_Necessity.Text; model.App_InstallCondition = tb_InstallCondition.Text; model.App_Positions = tb_PositionCode.Value.Trim(); model.App_LabType = ddl_LabType.SelectedValue; model.App_ConstructionType = ddl_ConType.SelectedValue; if (int.TryParse(tb_ApplyFinancing.Text, out Temp)) { if (Temp > 0) { model.App_ApplyFinancing = Temp; } } model.App_Necessity = tb_Necessity.Text; ///ʱ����� string[] DateTimeList = { "yyyy/M/d tt hh:mm:ss", "yyyy/MM/dd tt hh:mm:ss", "yyyy/MM/dd HH:mm:ss", "yyyy/M/d HH:mm:ss", "yyyy/MM/dd", "yyyy-MM-dd hh:mm:ss", "yyyy-MM-dd", "yyyy-M-d" }; try { DateTime AppTime = DateTime.ParseExact(tb_AppTime.Text, DateTimeList, System.Globalization.CultureInfo.InvariantCulture, System.Globalization.DateTimeStyles.AllowInnerWhite); DateTime CompleteTime = DateTime.ParseExact(tb_CompletionTime.Text, DateTimeList, System.Globalization.CultureInfo.InvariantCulture, System.Globalization.DateTimeStyles.AllowInnerWhite); if (DateTime.Compare(AppTime, CompleteTime) < 0) { model.App_AppTime = AppTime; model.App_CompletionTime = CompleteTime; } else { LabMS.Common.JShelper.JSAlert(this, "����ʱ��Ĵ�С�д���", "����ʱ��Ĵ�С�д������С������������"); return; } } catch { LabMS.Common.JShelper.JSAlert(this,"ʱ���ʽ����","ʱ���С�������ʱ���ʽ������ȷ�Ϻ�����д"); return; } try { App.Update(model); } catch(Exception ex) { lb_Error.Text = ex.Message; } LabMS.BLL.ConsumeApp ConsumeApp = new LabMS.BLL.ConsumeApp(); List<LabMS.Model.ConsumeApp> lsConsumeApp = new List<LabMS.Model.ConsumeApp>(); lsConsumeApp = ConsumeApp.GetModelList("AppID=" + model.ID); try { for (int n = 0; n < lsConsumeApp.Count; n++) { ConsumeApp.Delete(lsConsumeApp[n].ID); } } catch(Exception ex) { LabMS.Common.JShelper.JSAlert(this,"header",ex.Message); return; } LabMS.Model.ConsumeApp consumeappmodel; for (int i = 0; i < Index; i++) { consumeappmodel = new LabMS.Model.ConsumeApp(); int nums=0; decimal unitprice = new decimal(); try { if (Request.Form["code" + i] != null) { consumeappmodel.EquipType = Request.Form["code" + i]; consumeappmodel.EquipName = Request.Form["name" + i]; consumeappmodel.Model = Request.Form["model" + i]; consumeappmodel.Factory = Request.Form["factory" + i]; consumeappmodel.Argument = Request.Form["argument" + i]; decimal.TryParse(Request.Form["unitprice" + i], out unitprice); consumeappmodel.UnitPrice = unitprice; int.TryParse(Request.Form["num" + i], out nums); consumeappmodel.EquipNum = nums; consumeappmodel.AppID = model.ID; ConsumeApp.Add(consumeappmodel); } } catch (Exception ex) { LabMS.Common.JShelper.JSAlert(this, "header", ex.Message); return; } } if (!SaveItem(model)) { lb_Error.Text = "�����ļ�ʱ����"; } #endregion ������ Page.ClientScript.RegisterClientScriptBlock(GetType(), "script", "<script type='text/javascript'>alert('�ijɹ���');window.location='AppPreview.aspx" + "?ID=" + QueryString.ToString() + "';</script>"); }
protected void Gv_DataBinds() { if (HF_QueryString != QueryString || QueryString <= 0) { Page.ClientScript.RegisterClientScriptBlock(GetType(), "script", "<script type='text/javascript'>window.location.href='~/err.aspx?Message=��ѯ�ַ�������';</script>"); return; } LabMS.BLL.ConsumeApp ConsumeApp = new LabMS.BLL.ConsumeApp(); List<LabMS.Model.ConsumeApp> ls = new List<LabMS.Model.ConsumeApp>(); ls = ConsumeApp.GetModelList("AppID =" + QueryString); Gv_Equipment.DataSource = ls; Gv_Equipment.DataBind(); }
protected List<LabMS.Model.ConsumeApp> GetEquipmetList() { LabMS.BLL.ConsumeApp Equips = new LabMS.BLL.ConsumeApp(); List<LabMS.Model.ConsumeApp> ls = new List<LabMS.Model.ConsumeApp>(); int ID = QueryString; if (ID != 0) { ls = Equips.GetModelList("AppID=" + ID); } return ls; }
protected void Gv_DataBinds() { if (!string.IsNullOrEmpty(Request.QueryString["ID"] )) { int ID = 0; if (int.TryParse(Request.QueryString["ID"].ToString(), out ID)) { if (HFQueryString != ID) { Page.ClientScript.RegisterClientScriptBlock(GetType(), "script", "<script type='text/javascript'>window.location.href='err.aspx?Message=��ѯ�ַ�������'</script>'"); return; } LabMS.BLL.ConsumeApp ConsumeApp = new LabMS.BLL.ConsumeApp(); List<LabMS.Model.ConsumeApp> ls = new List<LabMS.Model.ConsumeApp>(); ls = ConsumeApp.GetModelList("AppID=" + ID.ToString()); Gv_Equip.DataSource = ls; Gv_Equip.DataBind(); } } else { lb_Error.Text = "��ѯ�ַ�������"; } }