Exemplo n.º 1
0
        protected void Save_Click(object sender, EventArgs e)
        {
            #region validation

            int Index = 0;
            int NewIndex = 0;
            if (!int.TryParse(tb_EIndex.Value, out Index))
            {
                Page.ClientScript.RegisterClientScriptBlock(GetType(), "script", "<script type='text/javascript'>alert('�������ݴ���');window.location.href='ProjectList.aspx';</script>");
                return;
            }
            if (!int.TryParse(tb_ConsumpIndex.Value, out NewIndex))
            {
                Page.ClientScript.RegisterClientScriptBlock(GetType(), "script", "<script type='text/javascript'>alert('�������ݴ���');window.location.href='ProjectList.aspx';</script>");
                return;
            }

            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["model" + i]))
                    {
                        LabMS.Common.JShelper.JSAlert(this, "error", "�������ͺŲ���Ϊ��");
                        return;
                    }
                    if (string.IsNullOrEmpty(Request.Form["categorycode" + i]))
                    {
                        LabMS.Common.JShelper.JSAlert(this, "error", "��������Ų���Ϊ��");
                        return;
                    }

                }
            }

            for (int j = 0; j < NewIndex; j++)
            {
                if (!string.IsNullOrEmpty(Request.Form["code" + j]) && !string.IsNullOrEmpty(Request.Form["name" + j]))
                {
                    if (string.IsNullOrEmpty(Request.Form["model" + j]))
                    {
                        LabMS.Common.JShelper.JSAlert(this, "error", "�����ͺŲ���Ϊ��");
                        return;
                    }
                    if (string.IsNullOrEmpty(Request.Form["categorycode" + j]))
                    {
                        LabMS.Common.JShelper.JSAlert(this, "error", "��������Ų���Ϊ��");
                        return;
                    }

                }
            }

            #endregion validation

            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"
                                     };
            LabMS.BLL.Project Project = new LabMS.BLL.Project();
            LabMS.Model.Project ProjectItem = new LabMS.Model.Project();

            ProjectItem = Project.GetModel(Convert.ToInt32(Request.QueryString["ID"].ToString()));

            ProjectItem.Project_Code = tb_Code.Text.Trim();
            ProjectItem.Project_Name = tb_Name.Text.Trim();
            ProjectItem.Project_StartTime = DateTime.ParseExact(tb_StartTime.Text.Trim(), DateTimeList, System.Globalization.CultureInfo.InvariantCulture, System.Globalization.DateTimeStyles.AllowInnerWhite);
            ProjectItem.Project_StartWeek = new int?(Convert.ToInt32(tb_StartWeek.Text.Trim()));
            ProjectItem.Project_SubmitTime = DateTime.Now;
            ProjectItem.Project_EndTime = DateTime.ParseExact(tb_EndTime.Text.Trim(), DateTimeList, System.Globalization.CultureInfo.InvariantCulture, System.Globalization.DateTimeStyles.AllowInnerWhite);
            ProjectItem.Project_EndWeek = new int?(Convert.ToInt32(tb_EndWeek.Text.Trim()));
            ProjectItem.Project_ClassHourse = new int?(Convert.ToInt32(tb_ClassHourse.Text.Trim()));

            ProjectItem.Project_Consume = new int?(Convert.ToInt32(tb_Cunsume.Text.Trim()));
            ProjectItem.Project_PartnerNum = Convert.ToInt32(tb_PatnerNum.Text.Trim());
            ProjectItem.Project_Content = tb_Content.Text.TrimEnd();
            ProjectItem.Project_Lab = new int?(Convert.ToInt32(ddl_Lab.SelectedValue));
            //ProjectItem.Project_PartnerTeamNum = Convert.ToInt32(tb_PatnerTeamNum.Text);
            ProjectItem.Project_ExpHouse = Convert.ToInt32(tb_ExpHouse.Text.Trim());
            ProjectItem.Project_Professional = Convert.ToInt32(ddl_Profess.SelectedValue);

            ProjectItem.Project_Category = ddl_Category.SelectedValue.Trim();
            ProjectItem.Project_AwardLevel = ddl_AwardLevel.SelectedValue.Trim();
            ProjectItem.Project_PartnerType = ddl_ParterType.SelectedValue.Trim();
            ProjectItem.Project_Request = ddl_Request.SelectedValue.Trim();
            ProjectItem.Project_Type = ddl_Type.SelectedValue.Trim();
            ProjectItem.Project_Change = ddl_Change.SelectedValue.Trim();
            ProjectItem.Project_Subject = tb_Subject.Text.Trim();

            ProjectItem.Project_CourseMode = "";
            for (int i = 0; i < cbl_CourseMode.Items.Count; i++)
            {
                if (cbl_CourseMode.Items[i].Selected == true)
                {
                    ProjectItem.Project_CourseMode += cbl_CourseMode.Items[i].Value + "|";
                }
            }
            Project.Update(ProjectItem);

            /// ���Equipment ��Ϣ

            int ProjectIDs = ProjectItem.ID;

            ///����
            ///
            LabMS.BLL.ProjectConsume ProjectConsume = new LabMS.BLL.ProjectConsume();

            List<LabMS.Model.ProjectConsume> ls = new List<LabMS.Model.ProjectConsume>();
            ls = ProjectConsume.GetModelList("ProjectID=" + ProjectIDs);
            try
            {
                for (int v = 0; v < ls.Count; v++)
                {
                    ProjectConsume.Delete(ls[v].ID);
                }
            }
            catch
            {
                Page.ClientScript.RegisterClientScriptBlock(GetType(), "script", "<script type='text/javascript'>alert('��������Ʒ��Ӵ���');window.location.href='ProjectList.aspx';</script>");
                return;
            }

            LabMS.Model.ProjectConsume projectconsumemodel;
            int temp = 0;
            decimal tem = 0.0M;
            for (int n = 0; n < Index; n++)
            {
                projectconsumemodel = new LabMS.Model.ProjectConsume();
                try
                {
                    if (!string.IsNullOrEmpty(Request.Form["code" + n]) && !string.IsNullOrEmpty(Request.Form["name" + n]))
                    {
                        projectconsumemodel.EquipType = Request.Form["code" + n];
                        projectconsumemodel.EquipName = Request.Form["name" + n];
                        projectconsumemodel.Model = Request.Form["model" + n];
                        projectconsumemodel.CategoryCode = Request.Form["categorycode" + n];
                        projectconsumemodel.Argument = Request.Form["argument" + n];
                        if (int.TryParse(Request.Form["num" + n], out temp))
                        {
                            projectconsumemodel.EquipNum = temp;
                        }
                        else
                        {
                            projectconsumemodel.EquipNum = 0;
                        }
                        projectconsumemodel.Type = "1";

                        projectconsumemodel.ProjectID = ProjectIDs;
                        ProjectConsume.Add(projectconsumemodel);

                    }
                }
                catch (Exception ex)
                {
                    Page.ClientScript.RegisterClientScriptBlock(GetType(), "script", "<script type='text/javascript'>alert('��������Ʒ��Ӵ���');window.location.href='ProjectList.aspx';</script>");
                    return;
                }

            }

            for (int m = 0; m < NewIndex; m++)
            {
                projectconsumemodel = new LabMS.Model.ProjectConsume();
                try
                {
                    if (!string.IsNullOrEmpty(Request.Form["consumpcode" + m]) && !string.IsNullOrEmpty(Request.Form["consumpname" + m]))
                    {
                        projectconsumemodel.EquipType = Request.Form["consumpcode" + m];
                        projectconsumemodel.EquipName = Request.Form["consumpname" + m];
                        projectconsumemodel.Model = Request.Form["consumpmodel" + m];
                        projectconsumemodel.CategoryCode = Request.Form["consumpcategorycode" + m];
                        projectconsumemodel.Argument = Request.Form["consumpargument" + m];
                        if (int.TryParse(Request.Form["consumpnum" + m], out temp))
                        {
                            projectconsumemodel.EquipNum = temp;
                        }
                        else
                        {
                            projectconsumemodel.EquipNum = 0;
                        }

                        if (decimal.TryParse(Request.Form["consumpunitprice" + m], out tem))
                        {
                            projectconsumemodel.UnitPrice = tem;
                        }
                        else
                        {
                            projectconsumemodel.UnitPrice = 0.0M;
                        }

                        if (decimal.TryParse(Request.Form["consumpmoney" + m].Trim(), out tem))
                        {
                            projectconsumemodel.Money = tem.ToString();
                        }
                        else
                        {
                            decimal unitpricetemp = 0.0M;
                            int numtemp = 0;
                            if (decimal.TryParse(Request.Form["consumpunitprice" + m].Trim(), out unitpricetemp) && int.TryParse(Request.Form["consumpnum" + m].Trim(), out numtemp))
                            {
                                decimal moneyall = unitpricetemp * numtemp;
                                projectconsumemodel.Money = moneyall.ToString();
                            }
                            else
                            {
                                projectconsumemodel.Money = "0.0";
                            }
                        }

                        projectconsumemodel.ProjectID = ProjectIDs;
                        projectconsumemodel.Type = "2";
                        ProjectConsume.Add(projectconsumemodel);

                    }
                }
                catch (Exception ex)
                {
                    Page.ClientScript.RegisterClientScriptBlock(GetType(), "script", "<script type='text/javascript'>alert('��������Ʒ��Ӵ���,����ϵ����Ա��');window.location.href='ProjectList.aspx';</script>");
                    return;
                }

            }

            Page.ClientScript.RegisterClientScriptBlock(GetType(), "script", "<script type='text/javascript'>alert('�޸ijɹ�');refreshParent();if(window.confirm('�Ƿ񷵻��б�ҳ��')){window.location.href='ProjectList.aspx';}else{window.location.href=window.location.href;}</script>");

            return;
        }
Exemplo n.º 2
0
        protected void DataBinds()
        {
            #region DataBinds
            int ID = Convert.ToInt32(Request.QueryString["ID"].ToString());
            LabMS.BLL.Project Project = new LabMS.BLL.Project();
            LabMS.Model.Project model = new LabMS.Model.Project();
            model = Project.GetModel(ID);
            //�����ݿ�ʼ

            LabMS.BLL.DictionaryClass DicClass = new LabMS.BLL.DictionaryClass();
            LabMS.Model.DictionaryClass ds = new LabMS.Model.DictionaryClass();
            LabMS.BLL.Dictionary Dic = new LabMS.BLL.Dictionary();
            List<LabMS.Model.Dictionary> ls = new List<LabMS.Model.Dictionary>();

            //ʵ����Ŀ��� Category
            if (DicClass.GetModelList("Code='Project_Category'").Count != 0)
            {
                ds = DicClass.GetModelList("Code='Project_Category'")[0];
                ls = Dic.GetModelList("DClass='" + ds.Code + "'");
                ddl_Category.DataSource = ls;
                ddl_Category.DataTextField = "Name";
                ddl_Category.DataValueField = "Code";
                ddl_Category.DataBind();
                if (!string.IsNullOrEmpty(model.Project_Category))
                {
                    ddl_Category.Items.FindByValue(model.Project_Category).Selected = true;
                }

            }
            // ʵ������Ŀ Lab

            LabMS.BLL.Lab Lab = new LabMS.BLL.Lab();
            List<LabMS.Model.Lab> ParentLab = new List<LabMS.Model.Lab>();
            ParentLab = Lab.GetModelList("Lab_ParentID is null");
            List<LabMS.Model.Lab> SonLab = new List<LabMS.Model.Lab>();
            SonLab = Lab.GetModelList("Lab_ParentID is not null");

            for (int i = 0; i < ParentLab.Count; i++)
            {
                ddl_Lab.Items.Add(new ListItem(ParentLab[i].Lab_Name, ParentLab[i].ID.ToString()));
                for (int j = 0; j < SonLab.Count; j++)
                {
                    if (SonLab[j].Lab_ParentID == ParentLab[i].ID)
                    {
                        ddl_Lab.Items.Add(new ListItem("--|" + SonLab[j].Lab_Name, SonLab[j].ID.ToString()));
                    }
                }
            }

            if (model.Project_Lab != null)
            {
                ddl_Lab.Items.FindByValue(model.Project_Lab.ToString()).Selected = true;
            }

            if (DicClass.GetModelList("Code='Project_AwardLevel'").Count != 0)
            {
                ds = DicClass.GetModelList("Code='Project_AwardLevel'")[0];
                ls = Dic.GetModelList("DClass='" + ds.Code + "'");
                ddl_AwardLevel.DataSource = ls;
                ddl_AwardLevel.DataTextField = "Name";
                ddl_AwardLevel.DataValueField = "Code";
                ddl_AwardLevel.DataBind();
                if (!string.IsNullOrEmpty(model.Project_AwardLevel))
                {
                    ddl_AwardLevel.Items.FindByValue(model.Project_AwardLevel).Selected = true;
                }
            }

            //ʵ��������

            if (DicClass.GetModelList("Code='Project_PartnerType'").Count != 0)
            {
                ds = DicClass.GetModelList("Code='Project_PartnerType'")[0];
                ls = Dic.GetModelList("DClass='" + ds.Code + "'");
                ddl_ParterType.DataSource = ls;
                ddl_ParterType.DataTextField = "Name";
                ddl_ParterType.DataValueField = "Code";
                ddl_ParterType.DataBind();
                if (!string.IsNullOrEmpty(model.Project_PartnerType))
                {
                    ddl_ParterType.Items.FindByValue(model.Project_PartnerType).Selected = true;
                }
            }

            if (DicClass.GetModelList("Code='Project_Type'").Count != 0)
            {
                ds = DicClass.GetModelList("Code='Project_Type'")[0];
                ls = Dic.GetModelList("DClass='" + ds.Code + "'");
                ddl_Type.DataSource = ls;
                ddl_Type.DataTextField = "Name";
                ddl_Type.DataValueField = "Code";
                ddl_Type.DataBind();
                if (!string.IsNullOrEmpty(model.Project_Type))
                {
                    ddl_Type.Items.FindByValue(model.Project_Type).Selected = true;
                }
            }

            if (DicClass.GetModelList("Code='Project_Request'").Count != 0)
            {
                ds = DicClass.GetModelList("Code='Project_Request'")[0];
                ls = Dic.GetModelList("DClass='" + ds.Code + "'");
                ddl_Request.DataSource = ls;
                ddl_Request.DataTextField = "Name";
                ddl_Request.DataValueField = "Code";
                ddl_Request.DataBind();
                if (!string.IsNullOrEmpty(model.Project_Request))
                {
                    ddl_Request.Items.FindByValue(model.Project_Request).Selected = true;
                }
            }

            if (DicClass.GetModelList("Code='Project_Change'").Count != 0)
            {
                ds = DicClass.GetModelList("Code='Project_Change'")[0];
                ls = Dic.GetModelList("DClass='" + ds.Code + "'");
                ddl_Change.DataSource = ls;
                ddl_Change.DataTextField = "Name";
                ddl_Change.DataValueField = "Code";
                ddl_Change.DataBind();
                if (!string.IsNullOrEmpty(model.Project_Change))
                {
                    ddl_Change.Items.FindByValue(model.Project_Change).Selected = true;
                }
            }

            if (DicClass.GetModelList("Code='Project_CourseMode'").Count != 0)
            {
                ds = DicClass.GetModelList("Code='Project_CourseMode'")[0];
                ls = Dic.GetModelList("DClass='" + ds.Code + "'");
                cbl_CourseMode.DataSource = ls;
                cbl_CourseMode.DataTextField = "Name";
                cbl_CourseMode.DataValueField = "Code";
                cbl_CourseMode.DataBind();
                string[] cm = model.Project_CourseMode.Split('|');
                foreach (string c in cm)
                {
                    if (!string.IsNullOrEmpty(c.Trim()))
                    {
                        cbl_CourseMode.Items.FindByValue(c.Trim()).Selected = true;
                    }
                }
            }

            // ����רҵ
            LabMS.BLL.Professional Pro = new LabMS.BLL.Professional();
            List<LabMS.Model.Professional> lsPro = new List<LabMS.Model.Professional>();
            lsPro = Pro.GetModelList("");
            if (lsPro.Count != 0)
            {
                ddl_Profess.DataSource = lsPro;
                ddl_Profess.DataTextField = "Pro_Name";
                ddl_Profess.DataValueField = "ID";
                ddl_Profess.DataBind();
                if (model.Project_Professional != null)
                {
                    ddl_Profess.Items.FindByValue(model.Project_Professional.ToString()).Selected = true;
                }
            }

            tb_ClassHourse.Text = model.Project_ClassHourse.ToString();
            tb_Code.Text = model.Project_Code;
            if (model.Project_EndTime != null)
            {
                tb_EndTime.Text = model.Project_EndTime.Value.ToShortDateString();
            }
            tb_EndWeek.Text = model.Project_EndWeek.ToString();
            tb_ExpHouse.Text = model.Project_ExpHouse.ToString();
            tb_Name.Text = model.Project_Name;
            tb_PatnerNum.Text = model.Project_PartnerNum.ToString();
            if (model.Project_StartTime != null)
            {
                tb_StartTime.Text = model.Project_StartTime.Value.ToShortDateString();
            }
            tb_StartWeek.Text = model.Project_StartWeek.ToString();
            tb_Content.Text = model.Project_Content;
            //tb_Subject.Text = model.Project_Subject;

            if (model.Project_Subject != "")
            {
                ls = Dic.GetModelList("Code='" + model.Project_Subject+"'");
                if (ls.Count > 0)
                {
                    tb_Subject.Text = ls[0].Name;
                    tb_SubjectCode.Text = ls[0].Code;
                }
            }
            tb_PerConsume.Text = model.Project_PerConsume.ToString();
            tb_Cunsume.Text = model.Project_Consume.ToString();

            #endregion
        }
Exemplo n.º 3
0
        //通过项目ID获取实验学时
        protected string GetExHourByProID(int ProjectID)
        {
            LabMS.BLL.Project pro = new LabMS.BLL.Project();
            LabMS.Model.Project proModel = new LabMS.Model.Project();
            string Hour;

            proModel = pro.GetModel(ProjectID);
            Hour = proModel.Project_ClassHourse.ToString();
            return Hour;
        }
Exemplo n.º 4
0
        protected void Submit_Click(object sender, EventArgs e)
        {
            if (tb_Code.Text.Trim() == "")
            {
                LabMS.Common.JShelper.JSAlert(this, "�������", "ʵ���Ų���Ϊ��");
                return;
            }
            if (Project_Name.Text.Trim() == "")
            {
                LabMS.Common.JShelper.JSAlert(this, "�������", "ʵ�����Ʋ���Ϊ��");
                return;
            }

            if (Project_Category.SelectedValue.Trim() == "0")
            {
                LabMS.Common.JShelper.JSAlert(this, "�������", "ʵ����Ŀ�����Ϊ��");
                return;
            }

            if (Project_Lab.SelectedValue.Trim() == "0")
            {
                LabMS.Common.JShelper.JSAlert(this, "�������", "��Ŀ����ʵ���Ҳ���Ϊ��");
                return;
            }

            if (Project_StartTime.Text.Trim() == "")
            {
                LabMS.Common.JShelper.JSAlert(this, "�������", "��Ŀ���ʱ�䲻��Ϊ��");
                return;
            }
            if (Project_EndTime.Text.Trim() == "")
            {
                LabMS.Common.JShelper.JSAlert(this, "�������", "��Ŀ���ʱ�䲻��Ϊ��");
                return;
            }

            if (Project_StartWeek.Text.Trim() == "" || !IsNumber(Project_StartWeek.Text.Trim()))
            {
                LabMS.Common.JShelper.JSAlert(this, "�������", "��Ŀ����ܴ�����������������Ƿ�Ϊ�ջ�ȷ������Ϊ����");
                return;
            }
            if (Project_EndWeek.Text.Trim() == "" || !IsNumber(Project_EndWeek.Text.Trim()))
            {
                LabMS.Common.JShelper.JSAlert(this, "�������", "��Ŀ�����ܴ�����������������Ƿ�Ϊ�ջ�ȷ������Ϊ����");
                return;
            }
            if ((Convert.ToInt32(Project_EndWeek.Text.Trim())) < Convert.ToInt32(Project_StartWeek.Text.Trim()))
            {
                LabMS.Common.JShelper.JSAlert(this, "�������", "��Ŀ�ܴδ�С����");
                return;
            }

            if (Project_ClassHourse.Text.Trim() == "" || !IsNumber(Project_ClassHourse.Text.Trim()))
            {
                LabMS.Common.JShelper.JSAlert(this, "�������", "ʵ��ѧʱ�������,���������Ƿ�Ϊ�ջ�ȷ������Ϊ����");
                return;
            }
            if (Project_ExpHouse.Text.Trim() == "" || !IsNumber(Project_ExpHouse.Text.Trim()))
            {
                LabMS.Common.JShelper.JSAlert(this, "�������", "��Ŀʵ��ѧʱ�������,���������Ƿ�Ϊ�ջ�ȷ������Ϊ����");
                return;
            }
            if (tb_SubjectCode.Text.Trim() == "")
            {
                LabMS.Common.JShelper.JSAlert(this, "�������", "��Ŀѧ�Ʋ���Ϊ��");
                return;
            }
            if (ddl_ParterType.SelectedValue == "0")
            {
                LabMS.Common.JShelper.JSAlert(this, "", "��ѡ��ʵ�������");
                return;
            }

            if (ddl_Type.SelectedValue == "0")
            {
                LabMS.Common.JShelper.JSAlert(this, "", "��ѡ��ʵ������");
                return;
            }
            if (ddl_Request.SelectedValue == "0")
            {
                LabMS.Common.JShelper.JSAlert(this, "", "��ѡ��ʵ������");
                return;
            }

            if (ddl_Profess.SelectedValue == "0")
            {
                LabMS.Common.JShelper.JSAlert(this, "�������", "��ѡ����Ӧ��רҵ");
                return;
            }
            #region Validate
            int Index = Convert.ToInt32(tb_EIndex.Value);
            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["model" + i]))
                    {
                        LabMS.Common.JShelper.JSAlert(this, "error", "�����ͺŲ���Ϊ��");
                        return;
                    }
                    if (string.IsNullOrEmpty(Request.Form["categorycode" + i]))
                    {
                        LabMS.Common.JShelper.JSAlert(this, "error", "�������Ų���Ϊ��");
                        return;
                    }
                    if (string.IsNullOrEmpty(Request.Form["argument" + i]))
                    {
                        LabMS.Common.JShelper.JSAlert(this, "error", "�����������");
                        return;
                    }
                }
            }
            int NewIndex = Convert.ToInt32(tb_ConsumpIndex.Value);
            for (int j = 0; j < NewIndex; j++)
            {

                if (!string.IsNullOrEmpty(Request.Form["consumpcode" + j]) && !string.IsNullOrEmpty(Request.Form["consumpname" + j]))
                {
                    if (string.IsNullOrEmpty(Request.Form["consumpmodel" + j]))
                    {
                        LabMS.Common.JShelper.JSAlert(this, "error", "����Ʒ�ͺŲ���Ϊ��");
                        return;
                    }
                    if (string.IsNullOrEmpty(Request.Form["consumpcategorycode" + j]))
                    {
                        LabMS.Common.JShelper.JSAlert(this, "error", "����Ʒ���Ų���Ϊ��");
                        return;
                    }
                    if (string.IsNullOrEmpty(Request.Form["consumpunitprice" + j]))
                    {
                        LabMS.Common.JShelper.JSAlert(this, "error", "����Ʒ���۲���Ϊ��");
                        return;
                    }
                }
            }

            #endregion Validate

            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"
                                     };
            LabMS.BLL.Project Project = new LabMS.BLL.Project();
            LabMS.Model.Project ProjectItem = new LabMS.Model.Project();

            try
            {
                DateTime StarTime = DateTime.ParseExact(Project_StartTime.Text.Trim(), DateTimeList, System.Globalization.CultureInfo.InvariantCulture, System.Globalization.DateTimeStyles.AllowInnerWhite);

                DateTime EndTime = DateTime.ParseExact(Project_EndTime.Text.Trim(), DateTimeList, System.Globalization.CultureInfo.InvariantCulture, System.Globalization.DateTimeStyles.AllowInnerWhite);
                if (DateTime.Compare(StarTime, EndTime) <= 0)
                {
                    ProjectItem.Project_StartTime = StarTime;
                    ProjectItem.Project_EndTime = EndTime;
                }
                else
                {
                    LabMS.Common.JShelper.JSAlert(this, "����ʱ���С����", "����ϸ�˶ԣ������ʱ��ʹ�С");
                    return;
                }

            }
            catch
            {
                LabMS.Common.JShelper.JSAlert(this, "ʱ���������", "��ȷ��ʱ�������ʽ��ʱ����Ⱥ�˳���Ƿ���ȷ");
                return;
            }

            ProjectItem.Project_Code = tb_Code.Text.Trim();
            ProjectItem.Project_Name = Project_Name.Text.Trim();
            ProjectItem.Project_StartWeek = new int?(Convert.ToInt32(Project_StartWeek.Text.Trim()));
            ProjectItem.Project_EndWeek = new int?(Convert.ToInt32(Project_EndWeek.Text.Trim()));
            ProjectItem.Project_ClassHourse = new int?(Convert.ToInt32(Project_ClassHourse.Text.Trim()));
            ProjectItem.Project_ExpHouse = Convert.ToInt32(Project_ExpHouse.Text.Trim());
            ProjectItem.Project_SubmitTime = DateTime.Now;
            if (IsNumber(Project_Cunsume.Text.Trim()) && !string.IsNullOrEmpty(Project_Cunsume.Text.Trim()))
            {
                ProjectItem.Project_Consume = new int?(Convert.ToInt32(Project_Cunsume.Text.Trim()));
            }
            if (IsNumber(Project_PatnerNum.Text.Trim()) && !string.IsNullOrEmpty(Project_PatnerNum.Text.Trim()))
            {
                ProjectItem.Project_PartnerNum = Convert.ToInt32(Project_PatnerNum.Text.Trim());
            }
            if (IsNumber(Project_PerConsume.Text.Trim()) && !string.IsNullOrEmpty(Project_PerConsume.Text.Trim()))
            {
                ProjectItem.Project_PerConsume = Convert.ToInt32(Project_PerConsume.Text.Trim());
            }

            ProjectItem.Project_Lab = new int?(Convert.ToInt32(Project_Lab.SelectedValue));
            ProjectItem.Project_Content = Project_Content.Text.TrimEnd();
            ProjectItem.Project_Professional = Convert.ToInt32(ddl_Profess.SelectedValue);
            ProjectItem.Project_Category = Project_Category.SelectedValue.Trim();
            ProjectItem.Project_AwardLevel = ddl_AwardLevel.SelectedValue.Trim();
            ProjectItem.Project_PartnerType = ddl_ParterType.SelectedValue.Trim();
            ProjectItem.Project_Request = ddl_Request.SelectedValue.Trim();
            ProjectItem.Project_Type = ddl_Type.SelectedValue.Trim();
            ProjectItem.Project_Change = ddl_Change.SelectedValue.Trim();
            ProjectItem.Project_Subject = tb_SubjectCode.Text;
            ProjectItem.Project_PartnerType = ddl_ParterType.SelectedValue;
            int teamnum = 0;
            if (int.TryParse(tb_TeamNum.Text.Trim(), out teamnum))
            {
                ProjectItem.Project_PartnerTeamNum = teamnum;
            }
            else
            {
                ProjectItem.Project_PartnerTeamNum = 0;
            }

            for (int i = 0; i < cbl_CourseMode.Items.Count; i++)
            {
                if (cbl_CourseMode.Items[i].Selected == true)
                {
                    ProjectItem.Project_CourseMode += cbl_CourseMode.Items[i].Value + "|";
                }
            }
            int ProjectID = Project.Add(ProjectItem);

            //���ʵ�����ĺͺIJ�

            int tem = 0;
            decimal temp;
            LabMS.BLL.ProjectConsume ProjectConsume = new LabMS.BLL.ProjectConsume();
            LabMS.Model.ProjectConsume model;
            for (int n = 0; n < Index; n++)
            {

                if (!string.IsNullOrEmpty(Request.Form["code" + n]) && !string.IsNullOrEmpty(Request.Form["name" + n]))
                {
                    model = new LabMS.Model.ProjectConsume();
                    model.EquipType = Request.Form["code" + n].ToString();
                    model.EquipName = Request.Form["name" + n].ToString();
                    model.Model = Request.Form["model" + n].ToString();
                    model.CategoryCode = Request.Form["categorycode" + n].ToString();
                    model.Argument = Request.Form["argument" + n].ToString();
                    if (int.TryParse(Request.Form["num" + n].ToString(), out tem))
                    {
                        model.EquipNum = tem;
                    }
                    model.Type = "1";

                    model.ProjectID = ProjectID;
                    try
                    {
                        ProjectConsume.Add(model);
                    }
                    catch (Exception ex)
                    {
                        Page.ClientScript.RegisterClientScriptBlock(GetType(), "script", "<script type='text/javascript'>alert('�����������," + ex.Message + "');window.location.href='ProjectList.aspx';</script>");
                    }

                }
            }
            for (int m = 0; m < NewIndex; m++)
            {
                if (!string.IsNullOrEmpty(Request.Form["consumpcode" + m]) && !string.IsNullOrEmpty(Request.Form["consumpname" + m]))
                {
                    model = new LabMS.Model.ProjectConsume();
                    model.EquipType = Request.Form["consumpcode" + m].ToString();
                    model.EquipName = Request.Form["consumpname" + m].ToString();
                    model.CategoryCode = Request.Form["consumpcategorycode" + m].ToString();
                    model.Model = Request.Form["consumpmodel" + m].ToString();
                    if (int.TryParse(Request["consumpnum" + m].ToString(), out tem))
                    {
                        model.EquipNum = tem;
                    }
                    else
                    {
                        model.EquipNum = 1;
                    }
                    if (decimal.TryParse(Request.Form["consumpunitprice" + m].ToString(), out temp))
                    {
                        model.UnitPrice = temp;
                    }
                    else
                    {
                        model.UnitPrice = 0.0M;
                    }

                    decimal money = (model.UnitPrice.Value * model.EquipNum.Value);
                    model.Money = money.ToString();
                    //if(!string.IsNullOrEmpty(Request.Form["consumpmoney"+m]))
                    //{
                    //    model.Money = Request.Form["consumpmoney" + m].ToString();
                    //}
                    //else
                    //{
                    //    model.Money = "0";
                    //}
                    model.Type = "2";
                    model.ProjectID = ProjectID;
                    try
                    {
                        ProjectConsume.Add(model);
                    }
                    catch (Exception ex)
                    {
                        Page.ClientScript.RegisterClientScriptBlock(GetType(), "script", "<script type='text/javascript'>alert('��������Ʒ����" + ex.Message + "');window.location.href='ProjectList.aspx';</script>");
                    }

                }
            }

            Page.ClientScript.RegisterClientScriptBlock(GetType(), "script", "<script type='text/javascript'>alert('��ӳɹ�,��������Ŀ�б�ҳ�棡');if(window.confirm('�����б�ҳ�棡')){window.location.href='ProjectList.aspx';}else{window.location.href='ProjectPre.aspx?ID=" + ProjectID + "'}; </script>");
            return;
        }
Exemplo n.º 5
0
        /// <summary>
        /// �õ�һ������ʵ��
        /// </summary>
        public LabMS.Model.Project GetModel(int ID)
        {
            StringBuilder strSql=new StringBuilder();
            strSql.Append("select  top 1 ID,Project_Code,Project_Category,Project_Name,Project_Lab,Project_StartTime,Project_EndTime,Project_ClassHourse,Project_ExpHouse,Project_AwardLevel,Project_PartnerType,Project_Type,Project_Consume,Project_Change,Project_PartnerNum,Project_Professional,Project_Content,Project_CourseMode,Project_SubmitTime,Project_Open,Project_PartnerTeamNum,OPProjectID,Project_StartWeek,Project_EndWeek,Project_Subject,Project_Request,Project_PerConsume from Project ");
            strSql.Append(" where ID=@ID ");
            SqlParameter[] parameters = {
                    new SqlParameter("@ID", SqlDbType.Int,4)};
            parameters[0].Value = ID;

            LabMS.Model.Project model=new LabMS.Model.Project();
            DataSet ds=DbHelperSQL.Query(strSql.ToString(),parameters);
            if(ds.Tables[0].Rows.Count>0)
            {
                if(ds.Tables[0].Rows[0]["ID"].ToString()!="")
                {
                    model.ID=int.Parse(ds.Tables[0].Rows[0]["ID"].ToString());
                }
                model.Project_Code=ds.Tables[0].Rows[0]["Project_Code"].ToString();
                model.Project_Category=ds.Tables[0].Rows[0]["Project_Category"].ToString();
                model.Project_Name=ds.Tables[0].Rows[0]["Project_Name"].ToString();
                if(ds.Tables[0].Rows[0]["Project_Lab"].ToString()!="")
                {
                    model.Project_Lab=int.Parse(ds.Tables[0].Rows[0]["Project_Lab"].ToString());
                }
                if(ds.Tables[0].Rows[0]["Project_StartTime"].ToString()!="")
                {
                    model.Project_StartTime=DateTime.Parse(ds.Tables[0].Rows[0]["Project_StartTime"].ToString());
                }
                if(ds.Tables[0].Rows[0]["Project_EndTime"].ToString()!="")
                {
                    model.Project_EndTime=DateTime.Parse(ds.Tables[0].Rows[0]["Project_EndTime"].ToString());
                }
                if(ds.Tables[0].Rows[0]["Project_ClassHourse"].ToString()!="")
                {
                    model.Project_ClassHourse=int.Parse(ds.Tables[0].Rows[0]["Project_ClassHourse"].ToString());
                }
                if(ds.Tables[0].Rows[0]["Project_ExpHouse"].ToString()!="")
                {
                    model.Project_ExpHouse=int.Parse(ds.Tables[0].Rows[0]["Project_ExpHouse"].ToString());
                }
                model.Project_AwardLevel=ds.Tables[0].Rows[0]["Project_AwardLevel"].ToString();
                model.Project_PartnerType=ds.Tables[0].Rows[0]["Project_PartnerType"].ToString();
                model.Project_Type=ds.Tables[0].Rows[0]["Project_Type"].ToString();
                if(ds.Tables[0].Rows[0]["Project_Consume"].ToString()!="")
                {
                    model.Project_Consume=int.Parse(ds.Tables[0].Rows[0]["Project_Consume"].ToString());
                }
                model.Project_Change=ds.Tables[0].Rows[0]["Project_Change"].ToString();
                if(ds.Tables[0].Rows[0]["Project_PartnerNum"].ToString()!="")
                {
                    model.Project_PartnerNum=int.Parse(ds.Tables[0].Rows[0]["Project_PartnerNum"].ToString());
                }
                if(ds.Tables[0].Rows[0]["Project_Professional"].ToString()!="")
                {
                    model.Project_Professional=int.Parse(ds.Tables[0].Rows[0]["Project_Professional"].ToString());
                }
                model.Project_Content=ds.Tables[0].Rows[0]["Project_Content"].ToString();
                model.Project_CourseMode=ds.Tables[0].Rows[0]["Project_CourseMode"].ToString();
                if(ds.Tables[0].Rows[0]["Project_SubmitTime"].ToString()!="")
                {
                    model.Project_SubmitTime=DateTime.Parse(ds.Tables[0].Rows[0]["Project_SubmitTime"].ToString());
                }
                model.Project_Open=ds.Tables[0].Rows[0]["Project_Open"].ToString();
                if(ds.Tables[0].Rows[0]["Project_PartnerTeamNum"].ToString()!="")
                {
                    model.Project_PartnerTeamNum=int.Parse(ds.Tables[0].Rows[0]["Project_PartnerTeamNum"].ToString());
                }
                if(ds.Tables[0].Rows[0]["OPProjectID"].ToString()!="")
                {
                    model.OPProjectID=int.Parse(ds.Tables[0].Rows[0]["OPProjectID"].ToString());
                }
                if(ds.Tables[0].Rows[0]["Project_StartWeek"].ToString()!="")
                {
                    model.Project_StartWeek=int.Parse(ds.Tables[0].Rows[0]["Project_StartWeek"].ToString());
                }
                if(ds.Tables[0].Rows[0]["Project_EndWeek"].ToString()!="")
                {
                    model.Project_EndWeek=int.Parse(ds.Tables[0].Rows[0]["Project_EndWeek"].ToString());
                }
                model.Project_Subject=ds.Tables[0].Rows[0]["Project_Subject"].ToString();
                model.Project_Request=ds.Tables[0].Rows[0]["Project_Request"].ToString();
                if(ds.Tables[0].Rows[0]["Project_PerConsume"].ToString()!="")
                {
                    model.Project_PerConsume=int.Parse(ds.Tables[0].Rows[0]["Project_PerConsume"].ToString());
                }
                return model;
            }
            else
            {
                return null;
            }
        }