コード例 #1
0
ファイル: AppEdit.aspx.cs プロジェクト: dalinhuang/labms
        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>");
        }
コード例 #2
0
ファイル: AppEdit.aspx.cs プロジェクト: dalinhuang/labms
        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;
        }
コード例 #3
0
ファイル: AppPreview.aspx.cs プロジェクト: dalinhuang/labms
 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 = "��ѯ�ַ�������";
     }
 }
コード例 #4
0
        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();
        }
コード例 #5
0
        protected void Submit_Click(object sender, EventArgs e)
        {
            #region Validation

            if (string.IsNullOrEmpty(App_ProjectCode.Text.Trim()))
            {
                LabMS.Common.JShelper.JSAlert(this, "�������ݴ���", "����д��Ŀ���");
                return;
            }
            if (string.IsNullOrEmpty(App_Code.Text.Trim()))
            {
                LabMS.Common.JShelper.JSAlert(this, "�������ݴ���", "����д��Ŀ����");
                return;
            }
            if (App_LabName.SelectedValue.Trim() == "0")
            {
                LabMS.Common.JShelper.JSAlert(this, "�������ݴ���", "ѡ��ʵ���Ҳ���Ϊ��");
                return;
            }
            if (App_LabType.SelectedValue == "0")
            {
                LabMS.Common.JShelper.JSAlert(this, "�������ݴ���", "��Ŀ��ʵ�������Ͳ���Ϊ��");
                return;
            }
            if (App_ConstructionType.SelectedValue == "0")
            {
                LabMS.Common.JShelper.JSAlert(this, "�������ݴ���", "��Ŀ�Ľ������Ͳ���Ϊ��");
                return;
            }
            if (string.IsNullOrEmpty(App_AppTime.Text.Trim()))
            {
                LabMS.Common.JShelper.JSAlert(this, "�������ݴ���", "����ӵ�����ʱ�䲻��Ϊ��");
                return;
            }
            if (string.IsNullOrEmpty(App_CompletionTime.Text.Trim()))
            {
                LabMS.Common.JShelper.JSAlert(this, "�������ݴ���", "����ӵ����ʱ�䲻��Ϊ��");
                return;
            }
            if (string.IsNullOrEmpty(App_InCharge.Text.Trim()))
            {
                LabMS.Common.JShelper.JSAlert(this, "�������ݴ���", "��Ŀ�����˲���Ϊ��");
                return;
            }
            else
            {
                if (System.Text.Encoding.Default.GetByteCount(App_InCharge.Text) > 50 )
                {
                    LabMS.Common.JShelper.JSAlert(this, "�������ݳ��ȴ���", "��Ŀ�������������Ȳ�����25�����֣�50��Ӣ���ַ�");
                }
            }

            if (string.IsNullOrEmpty(App_Phone.Text.Trim()))
            {
                LabMS.Common.JShelper.JSAlert(this, "�������ݴ���", "��ϵ�绰����Ϊ��");
                return;
            }
            if (string.IsNullOrEmpty(App_ApplyFinancing.Text.Trim()))
            {
                LabMS.Common.JShelper.JSAlert(this, "��Ҫ��������", "����д�������ʽ���Ϊ��");
                return;
            }

            if (HttpContext.Current.Request.Files.Count - 1 <= 0)
            {
                LabMS.Common.JShelper.JSAlert(this, "��Ҫ������", "���ϴ������鸽��");
            }

            int Index = int.Parse(tb_EIndex.Value);
            decimal tempde=0.0M;
            int temp=0;
            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(this, "error", "���������������ܿ�");
                        return;
                    }
                    else
                    {
                        if (!int.TryParse(Request.Form["num" + i], out temp))
                        {
                            LabMS.Common.JShelper.JSAlert(this, "error", "��������������������");
                            return;
                        }
                    }
                    if (string.IsNullOrEmpty(Request.Form["unitprice" + i]))
                    {
                        LabMS.Common.JShelper.JSAlert(this, "error", "�����������۲���Ϊ�գ�Ӧ��Ϊ������С��");
                        return;
                    }
                    else
                    {
                        if (!decimal.TryParse(Request.Form["unitprice" + i], out tempde))
                        {
                            LabMS.Common.JShelper.JSAlert(this, "error", "������������Ӧ��Ϊ������С����");
                            return;
                        }
                    }

                }
            }

            #endregion Validation

            LabMS.BLL.ProjectApp ProjectApp = new LabMS.BLL.ProjectApp();
            LabMS.Model.ProjectApp model = new LabMS.Model.ProjectApp();
            model.App_Code = App_Code.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(App_AppTime.Text, DateTimeList, System.Globalization.CultureInfo.InvariantCulture, System.Globalization.DateTimeStyles.AllowInnerWhite);
                DateTime CompleteTime=DateTime.ParseExact(App_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;
            }

            model.App_InCharge = App_InCharge.Text;
            model.App_Phone = App_Phone.Text;
            model.App_Location = App_Loction.Text.TrimEnd();
            model.App_InstallCondition = App_InstallCondition.Text.TrimEnd();
            model.App_Necessity = App_Necessity.Text.TrimEnd();
            model.App_LabType = App_LabType.SelectedValue;
            model.App_ConstructionType = App_ConstructionType.SelectedValue;
            model.App_State = "SubmitNotYet";

            model.LabID = Convert.ToInt32(App_LabName.SelectedValue.Trim());

            model.App_Positions = tb_PositonCode.Text.Trim();

            model.App_ApplyFinancing = Convert.ToInt32(App_ApplyFinancing.Text);
            model.App_ProjectCode = App_ProjectCode.Text.Trim();

            int attachID=0;
            bool saved = false;
            if ((HttpContext.Current.Request.Files.Count-1)>0)
            {
                try
                {
                    int count = HttpContext.Current.Request.Files.Count;
                    HttpFileCollection Files = HttpContext.Current.Request.Files;
                    string savePath = HttpContext.Current.Request.MapPath(@"../Content/UpLoadFile/");

                    List<string> fileNames = LabMS.Common.FileUpload.SaveFiles(Files, savePath);

                    LabMS.Model.Attachment attachmodel = new LabMS.Model.Attachment();

                    LabMS.BLL.Attachment Attach = new LabMS.BLL.Attachment();
                    attachID = Attach.Add(attachmodel);

                    if (attachID != 0)
                    {
                        LabMS.BLL.AttachmentItem AttachItem = new LabMS.BLL.AttachmentItem();
                        LabMS.Model.AttachmentItem itemmodel;

                        for (int n = 0; n < fileNames.Count; n++)
                        {
                            if (fileNames[n].Trim() != "")
                            {
                                itemmodel = new LabMS.Model.AttachmentItem();
                                itemmodel.Item_Address = "Content/UpLoadFile/"+fileNames[n].Trim();
                                int index = fileNames[n].LastIndexOf("_");
                                itemmodel.Item_Name = fileNames[n].Substring(0, fileNames[n].LastIndexOf("_"));
                                itemmodel.Attach_ID = attachID;
                                itemmodel.Item_Type = "1";
                                AttachItem.Add(itemmodel);
                            }
                        }
                    }
                    saved = true;
                }
                catch
                {
                    Page.ClientScript.RegisterClientScriptBlock(GetType(), "script", "<script type='text/javascript'>alert('�ϴ��ļ�ʱ��������ϵ����Ա��');window.location.href='ApplicationList.aspx'; </script>");
                    return;
                }

            }

            if (saved)
            {
                model.App_Attachment = attachID;
            }
            int appid = ProjectApp.Add(model);

            LabMS.Model.ConsumeApp consumeappmodel;
            LabMS.BLL.ConsumeApp ConsumeApp = new LabMS.BLL.ConsumeApp();
            for (int i = 0; i < Index; i++)
            {
                consumeappmodel = new LabMS.Model.ConsumeApp();

                int nums = 0;
                decimal unitprice = new decimal();

                try
                {
                    if (!string.IsNullOrEmpty(Request.Form["code" + i.ToString()+""]) )
                    {
                        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 = appid;
                        ConsumeApp.Add(consumeappmodel);
                    }

                }
                catch (Exception ex)
                {
                    LabMS.Common.JShelper.JSAlert(this, "header", ex.Message);
                    return;
                }

            }

            Page.ClientScript.RegisterClientScriptBlock(GetType(), "script", "<script type='text/javascript'>alert('��������Ŀ�б�ҳ�棡');window.location.href='ApplicationList.aspx'; </script>");
            return;
        }