Ejemplo n.º 1
0
        /// <summary>
        /// 返回一个AttachmentID
        /// </summary>
        /// <param></param>
        /// <returns></returns>
        protected int AttachmentSave()
        {
            int Attach_ID = 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> fileName = LabMS.Common.FileUpload.SaveFiles(Files, savePath);
                    LabMS.BLL.Attachment Attachment = new LabMS.BLL.Attachment();
                    LabMS.Model.Attachment attachmentmodel = new LabMS.Model.Attachment();
                    Attach_ID = Attachment.Add(attachmentmodel);

                    if (Attach_ID != 0)
                    {
                        LabMS.BLL.AttachmentItem AttachItem = new LabMS.BLL.AttachmentItem();
                        LabMS.Model.AttachmentItem attachmentitemmodel;
                        for (int n = 0; n < fileName.Count; n++)
                        {
                            if (fileName[n].Trim() != "")
                            {
                                attachmentitemmodel = new LabMS.Model.AttachmentItem();
                                attachmentitemmodel.Attach_ID = Attach_ID;
                                attachmentitemmodel.Item_Address = "Content/UpLoadFile/" + fileName[n].Trim();
                                attachmentitemmodel.Item_Name = fileName[n].Substring(0, fileName[0].LastIndexOf("_"));
                                attachmentitemmodel.Item_Type = "3";
                                AttachItem.Add(attachmentitemmodel);
                            }
                        }
                    }
                    saved = true;
                }
                catch (Exception ex)
                {
                    lbErr.Text = ex.Message;
                }
                finally
                {
                    if (saved == false)
                    {

                    }
                }
            }
            return Attach_ID;
        }
Ejemplo n.º 2
0
        //������Ϣ
        protected void SaveOnClick(object sender, EventArgs e)
        {
            if (CodeNumTBX.Text.Trim() == "")
            {
                Page.ClientScript.RegisterClientScriptBlock(GetType(), "", "<script type='text/javascript'>alert('�������ĺţ�')</script>");
                return;
            }
            if (TitleTBX.Text.Trim() == "")
            {
                Page.ClientScript.RegisterClientScriptBlock(GetType(), "", "<script type='text/javascript'>alert('��������⣡')</script>");
                return;
            }
            if (IsCode(CodeNumTBX.Text.ToString().Trim()))
            {
                Page.ClientScript.RegisterClientScriptBlock(GetType(), "", "<script type='text/javascript'>alert('�Ѵ��ڸ��ĺźţ����������룡')</script>");
                return;
            }
            LabMS.Model.Rule rule = new LabMS.Model.Rule();
            //LabMS.BLL.Rule ruleinfo = new LabMS.BLL.Rule();
            ExtendBLL.Rule ruleinfo = new ExtendBLL.Rule();

            rule.Rule_CodeNum = CodeNumTBX.Text;//�ĺ�
            rule.Rule_Content = LabMS.Common.codehelper.Encode(ResourceContent.Text.Trim());//����
            if (ModifyDateTBX.Text != "")
            {
                rule.Rule_Date = DateTime.Parse(ModifyDateTBX.Text);//����
            }
            rule.Rule_InputUnit = InputUnitDDL.SelectedValue;//¼�뵥λ
            rule.Rule_KeyWord = KeyTBX.Text;//�ؼ���
            rule.Rule_OutputUnit = OutputUnitTBX.Text.Trim();//���ĵ�λ
            rule.Rule_SubTitle = SubTitleTBX.Text.Trim();//�ӱ���
            rule.Rule_Title = TitleTBX.Text.Trim();//����
            rule.Rule_Type = RuleKindDDL.SelectedValue;//����

            LabMS.BLL.Attachment att = new LabMS.BLL.Attachment();
            LabMS.Model.Attachment attModel = new LabMS.Model.Attachment();
            int AttachID=0;
            if (AttachIDHF.Value != "")
            {
                AttachID = int.Parse(AttachIDHF.Value);
            }
            HttpFileCollection uploads = HttpContext.Current.Request.Files;
            if (uploads.Count > 1)
            {
                if (AttachIDHF.Value == "")
                {
                    AttachID = att.Add(attModel);
                }
                for (int i = 0; i < uploads.Count; i++)
                {
                    HttpPostedFile upload = uploads[i];
                    Random objRand = new Random();
                    System.DateTime date = DateTime.Now;
                    int fileLength = upload.ContentLength;
                    string filename = upload.FileName;
                    string saveName = date.Year.ToString() + date.Month.ToString() + date.Day.ToString() + Convert.ToString(objRand.Next(99)) + upload.FileName;
                    if (fileLength == 0)
                    {
                        continue;
                    }
                    //�ж��ļ���С�Ƿ񳬹�200K
                    if (fileLength > (2000 * 1024))
                    {
                        Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "script", "<script type='text/javascript'>alert('�ļ���" + filename + ",̫��(���ܳ���2M)��')</script>");
                        return;
                    }
                    string fileURL = "Content/UploadFile" + "/" + saveName;
                    try
                    {
                        upload.SaveAs(Server.MapPath("../Content/UploadFile") + "/" + saveName);

                        LabMS.BLL.AttachmentItem attIte = new LabMS.BLL.AttachmentItem();
                        LabMS.Model.AttachmentItem attIteModel = new LabMS.Model.AttachmentItem();

                        attIteModel.Attach_ID = AttachID;
                        attIteModel.Item_Address = fileURL;
                        attIteModel.Item_Name = filename;

                        attIte.Add(attIteModel);
                    }
                    catch
                    {
                        Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "script", "<script type='text/javascript'>alert('����ļ�ʧ�ܣ�');</script>");
                        return;
                    }
                }

            }
            if (AttachID == 0)
            {
                rule.AttachmentID = null;//����
            }
            else
            {
                rule.AttachmentID = AttachID;//����
            }
            if (ViewState["ID"] != null)
            {
                DeleteAttach();//ɾ������
                rule.ID = int.Parse(ViewState["ID"].ToString());
                ruleinfo.Update(rule);
                Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "script", "<script type='text/javascript'>alert('������Ϣ�ɹ���');refreshParent();window.close();</script>");
            }
            else
            {
                ruleinfo.Add(rule);//���һ������Ϣ
                Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "script", "<script type='text/javascript'>alert('������Ϣ�ɹ���');refreshParent();window.location.href='AddRule.aspx';</script>");
            }
        }
Ejemplo n.º 3
0
        protected bool SaveItem(LabMS.Model.ProjectApp applicationmodel)
        {
            bool save = false;
            if (applicationmodel != null)
            {
                int Attach_ID = 0;
                if (applicationmodel.App_Attachment == null)
                {
                    if (HttpContext.Current.Request.Files.Count - 1 > 0)
                    {
                        LabMS.Model.Attachment attachmodel = new LabMS.Model.Attachment();
                        LabMS.BLL.Attachment Attach = new LabMS.BLL.Attachment();
                        applicationmodel.App_Attachment = Attach.Add(attachmodel);
                    }
                }
                else
                {
                    Attach_ID = applicationmodel.App_Attachment.Value;
                }

                if (Attach_ID != 0)
                {
                    //ɾ��
                    try
                    {
                        LabMS.BLL.AttachmentItem AttachItem = new LabMS.BLL.AttachmentItem();
                        List<LabMS.Model.AttachmentItem> ls = new List<LabMS.Model.AttachmentItem>();
                        ls = AttachItem.GetModelList("Item_Type='1' and  Attach_ID=" + Attach_ID);
                        string[] array1 = itemIDs.Value.Split(',');
                        if (array1[0] != "")
                        {
                            for (int i = 0; i < array1.Length; i++)
                            {
                                int itemid = 0;
                                if (int.TryParse(array1[i], out itemid))
                                {
                                    AttachItem.Delete(itemid);
                                }
                            }
                        }
                    }
                    catch(Exception ex)
                    {
                        lb_Error.Text = ex.Message;
                    }
                    //���

                    if (HttpContext.Current.Request.Files.Count-1 > 0)
                    {
                        try
                        {
                            LabMS.BLL.AttachmentItem AttachItem = new LabMS.BLL.AttachmentItem();
                            LabMS.Model.AttachmentItem itemmodel;
                            HttpFileCollection Files = HttpContext.Current.Request.Files;
                            string savePath = Request.MapPath(@"../Content/UpLoadFile/");
                            List<string> fileNames = LabMS.Common.FileUpload.SaveFiles(Files, savePath);

                            for (int n = 0; n < fileNames.Count; n++)
                            {
                                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 = Attach_ID;
                                itemmodel.Item_Type = "1";
                                AttachItem.Add(itemmodel);
                            }
                            save = true;
                        }
                        catch
                        {
                            save = false;
                        }
                    }
                }

            }

            return save;
        }
Ejemplo n.º 4
0
        protected void btn_AddEval_Click(object sender, EventArgs e)
        {
            if (QueryString != HFQueryString || QueryString <= 0)
            {
                Page.ClientScript.RegisterClientScriptBlock(GetType(), "script", "<script type='text/javascript' >alert('��ѯ�ַ�������');window.location.href='';</script>");
                return;
            }

            int ID = QueryString;
            if (ID > 0)
            {
                try
                {
                    bool save = false;
                    LabMS.BLL.ProjectApp Application = new LabMS.BLL.ProjectApp();
                    LabMS.Model.ProjectApp model = Application.GetModel(ID);
                    if (model != null)
                    {
                        if (HttpContext.Current.Request.Files.Count - 1 > 0)
                        {
                            int Attach_ID = model.App_Attachment.Value;
                            if (model.App_Attachment == null)
                            {
                                LabMS.BLL.Attachment Attach = new LabMS.BLL.Attachment();
                                LabMS.Model.Attachment attachmodel = new LabMS.Model.Attachment();
                                Attach_ID = Attach.Add(attachmodel);
                                model.App_Attachment = Attach_ID;
                            }
                            else
                            {
                                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);

                                if (Attach_ID != 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 = Attach_ID;
                                            itemmodel.Item_Type = "4";
                                            AttachItem.Add(itemmodel);
                                        }
                                    }
                                }
                                save = true;
                            }
                        }
                        else
                        {
                            Page.ClientScript.RegisterClientScriptBlock(GetType(), "script", "<script type='text/javascript' >alert('�ļ�����Ϊ��');window.location.href='';</script>");
                            return;
                        }
                        model.App_ExamineView = tb_ExamineView.Text;
                        model.App_State = "Examined";
                        model.App_AcceptanceTime = DateTime.Now;
                        Application.Update(model);
                        Page.ClientScript.RegisterClientScriptBlock(GetType(), "script", "<script type='text/javascript' >if(window.confirm('�Ƿ񷵻��б�ҳ��')){window.location.href='AppExaminedList.aspx';}else{window.location.href=window.location.href;}</script>");
                        return;
                    }
                }
                catch
                {
                    Page.ClientScript.RegisterClientScriptBlock(GetType(), "script", "<script type='text/javascript' >alert('���ݴ�ȡ����,����ϵ����Ա');window.location.href='';</script>");
                    return;
                }
            }
        }
Ejemplo n.º 5
0
        //�ύ�½�ʵ��������
        protected void Save_OnClick(object sender, EventArgs e)
        {
            if (LabNameTBX.Text.Trim() == "")
            {
                Page.ClientScript.RegisterClientScriptBlock(GetType(), "", "<script type='text/javascript'>alert('������ʵ��������!')</script>");
                return;
            }
            if (LabNumTBX.Text.Trim() == "")
            {
                Page.ClientScript.RegisterClientScriptBlock(GetType(), "", "<script type='text/javascript'>alert('������ʵ���ұ��!')</script>");
                return;
            }
            //�ж��Ƿ��Ѵ��ڸ�ʵ���ұ��
            if (IsCode(LabNumTBX.Text.ToString().Trim()))
            {
                Page.ClientScript.RegisterClientScriptBlock(GetType(), "", "<script type='text/javascript'>alert('�Ѵ��ڸ�ʵ���ұ�ţ����������룡')</script>");
                return;
            }
            //�ϴ��ļ���ȡ����IDֵ
            //int id = UpdateFile();
            //�ж��Ƿ񸽼�����
            //if (id == -1)
            //{
            //    Page.ClientScript.RegisterClientScriptBlock(GetType(), "", "<script type='text/javascript'>alert('�ϴ�ʧ�ܣ��ϴ����ļ����ܴ���4M��')</script>");
            //    return;
            //}
            //��ȡʵ������Ϣ
            LabMS.Model.Lab lab = new LabMS.Model.Lab();//����һ��lab����
            //if (id != 0)
            //{
            //    lab.Lab_Summary = id;//��ȡ���ID
            //}
            lab.Lab_Code = LabNumTBX.Text.ToString().Trim();//��ȡʵ���ұ��
            lab.Lab_Name = LabNameTBX.Text.ToString().Trim();//��ȡʵ��������
            lab.Lab_Category = LabKindDDL.SelectedValue.Trim();//��ȡʵ�������
            lab.Lab_Level = LabLevelDDL.SelectedValue.Trim();//��ȡʵ���Ҽ���
            if (DateTBX.Text.Trim() != "")
            {
                lab.Lab_SetupTime = DateTime.Parse(DateTBX.Text.Trim());//��ȡʵ���ҽ������
            }
            lab.Lab_InCharge = ManagerTBX.Text.ToString().Trim();//��ȡʵ���Ҹ�����
            lab.Lab_Phone = TelTBX.Text.ToString().Trim();//��ȡ��ϵ�绰
            lab.Lab_State = StatusDDL.SelectedValue.Trim();//��ȡʹ��״̬
            lab.Lab_Curriculum = CurriculumTBX.Text.ToString().Trim();//��ȡ��Ҫ�е��γ�
            lab.Lab_Type = LabTypeDDL.SelectedValue.Trim();//��ȡʵ��������
            lab.Lab_Disciplines = SubjectTBX.Text.Trim();//��ȡ����ѧ��
            lab.Lab_AwardLevel = AwardLevelDDL.SelectedValue.Trim();//��ȡ��������
            lab.Lab_ApprovalCode = NumTXB.Text.ToString().Trim();//��ȡ��׼�ĺ�
            lab.Lab_Professional = ProfessionTBX.Text.ToString().Trim();//��ȡ����רҵ
            lab.Lab_Statement = StatementTBX.Text.Trim();//��ע
            //��ȡ���м���Ŀ������
            if (ProjectNumTBX.Text.ToString().Trim() != "")
            {
                int i;
                if (int.TryParse(ProjectNumTBX.Text.Trim(), out i))
                {
                    lab.Lab_ProjectNum = i;
                }
                else
                {
                    Page.ClientScript.RegisterClientScriptBlock(GetType(), "", "<script type='text/javascript'>alert('���м���Ŀ������ֻ����������!')</script>");
                    return;
                }
            }
            lab.Lab_Investment = InvestmentTBX.Text.ToString().Trim();//��ȡͶ�ʽ��
            //ѧ������
            if (AwardNumTBX.Text.ToString().Trim() != "")
            {
                int i;
                if (int.TryParse(AwardNumTBX.Text.Trim(), out i))
                {
                    lab.Lab_StAwardNum = i;
                }
                else
                {
                    Page.ClientScript.RegisterClientScriptBlock(GetType(), "", "<script type='text/javascript'>alert('ѧ������ֻ����������!')</script>");
                    return;
                }
            }

            //�ϴ�����
            LabMS.BLL.Attachment att = new LabMS.BLL.Attachment();
            LabMS.Model.Attachment attModel = new LabMS.Model.Attachment();
            int AttachID = 0;
            if (AttachIDHF.Value != "")
            {
                AttachID = int.Parse(AttachIDHF.Value);
            }
            HttpFileCollection uploads = HttpContext.Current.Request.Files;
            if (uploads.Count > 1)
            {
                if (AttachIDHF.Value == "")
                {
                    AttachID = att.Add(attModel);
                }
                for (int i = 1; i < uploads.Count; i++)
                {

                    HttpPostedFile upload = uploads[i];
                    Random objRand = new Random();
                    System.DateTime date = DateTime.Now;
                    int fileLength = upload.ContentLength;
                    string filename = upload.FileName;
                    string saveName = date.Year.ToString() + date.Month.ToString() + date.Day.ToString() + Convert.ToString(objRand.Next(99)) + upload.FileName;
                    //if (fileLength == 0)
                    //{
                    //    Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "script", "<script type='text/javascript'>alert('�ļ���" + filename + "�ϴ�ʧ�ܣ���Ϊ���ļ�Ϊ���ļ���')</script>");
                    //    continue;
                    //}
                    //�ж��ļ���С�Ƿ񳬹�2000K
                    if (fileLength > (2000 * 1024))
                    {
                        Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "script", "<script type='text/javascript'>alert('�ļ���" + filename + "�ϴ�ʧ�ܣ���Ϊ���ļ�̫��(���ܳ���2M)��')</script>");
                        return;
                    }
                    string fileURL = "Content/UploadFile/" + saveName;
                    try
                    {
                        upload.SaveAs(Server.MapPath("../Content/UploadFile") + "/" + saveName);

                        LabMS.BLL.AttachmentItem attIte = new LabMS.BLL.AttachmentItem();
                        LabMS.Model.AttachmentItem attIteModel = new LabMS.Model.AttachmentItem();

                        attIteModel.Attach_ID = AttachID;
                        attIteModel.Item_Address = fileURL;
                        attIteModel.Item_Name = filename;

                        attIte.Add(attIteModel);
                    }
                    catch
                    {
                        Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "script", "<script type='text/javascript'>alert('����ļ�ʧ�ܣ�');</script>");
                        return;
                    }
                }

            }
            if (AttachID == 0)
            {
                lab.Lab_Summary = null;//����
            }
            else
            {
                lab.Lab_Summary = AttachID;//����
            }

            //�ύ����
            if (IDHF.Value != "0")
            {
                DeleteAttach();//ɾ������
                lab.ID = int.Parse(IDHF.Value);
                LabMS.BLL.Lab labdata = new LabMS.BLL.Lab();
                labdata.Update(lab);
                Page.ClientScript.RegisterClientScriptBlock(GetType(), "", "<script type='text/javascript'>alert('���³ɹ���');refreshParent();window.close();</script>");
            }
            else
            {
                LabMS.BLL.Lab labdata = new LabMS.BLL.Lab();
                labdata.Add(lab);
                Page.ClientScript.RegisterClientScriptBlock(GetType(), "", "<script type='text/javascript'>alert('��ӳɹ���');window.location.href='AddNewLab.aspx';</script>");
            }
        }
Ejemplo n.º 6
0
        protected void Submit_Click(object sender, EventArgs e)
        {
            if (!string.IsNullOrEmpty(itemIDs.Value))
            {
                string[] array1 = itemIDs.Value.Split(',');
                for (int m = 0; m < array1.Length; m++)
                {
                    if (array1[m] != "0"||array1[m]!="")
                    {
                        LabMS.BLL.AttachmentItem AttachItem = new LabMS.BLL.AttachmentItem();
                        AttachItem.Delete(Convert.ToInt32(array1[m]));
                    }
                }
            }
            int attachID = 0;
            if ((HttpContext.Current.Request.Files.Count - 1) > 0)
            {
                bool Result = false;
                try
                {
                    LabMS.BLL.ProjectApp Application = new LabMS.BLL.ProjectApp();
                    LabMS.Model.ProjectApp model = new LabMS.Model.ProjectApp();
                    model = Application.GetModel(QueryString);
                    if (model.App_Attachment == null)
                    {
                        attachID = 0;
                    }
                    else
                    {
                        attachID = model.App_Attachment.Value;
                    }

                    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);

                    if (attachID == 0)
                    {
                        LabMS.BLL.Attachment Attach = new LabMS.BLL.Attachment();
                        LabMS.Model.Attachment attachmodel = new LabMS.Model.Attachment();
                        attachID = Attach.Add(attachmodel);
                        model.App_Attachment = attachID;

                    }

                    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();
                            itemmodel.Item_Name = fileNames[n].Substring(0, fileNames[n].LastIndexOf("_"));
                            itemmodel.Attach_ID = attachID;
                            itemmodel.Item_Type = "2";
                            AttachItem.Add(itemmodel);
                        }
                    }
                    Result = true;

                    Application.Update(model);
                }
                catch
                {
                    Page.ClientScript.RegisterClientScriptBlock(GetType(), "script", "<script type='text/javascript'>alert('�ϴ��ļ�ʱ��������ϵ����Ա��');window.location.href=window.location.href; </script>");
                    return;
                }

                if (Result)
                {
                    Build.Visible = true;
                }
            }
            else
            {
                Page.ClientScript.RegisterClientScriptBlock(GetType(), "script", "<script type='text/javascript'>alert('û�������飬��ѡ����������ϴ���'); </script>");
                return;
            }
            Page.ClientScript.RegisterClientScriptBlock(GetType(), "script", "<script type='text/javascript'>if(window.confirm('���������ɹ����Ƿ񷵻��б�')){ window.location.href='AppTaskList.aspx';}else{window.location.href=window.location.href;}</script>");
            return;
        }
Ejemplo n.º 7
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;
        }