Пример #1
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;
        }
Пример #2
0
        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>");
        }
Пример #3
0
        /// <summary>
        /// �õ�һ������ʵ��
        /// </summary>
        public LabMS.Model.ConsumeApp GetModel(int AppID,int ID)
        {
            StringBuilder strSql=new StringBuilder();
            strSql.Append("select  top 1 ID,AppID,EquipType,EquipNum,UnitPrice,Argument,Factory,Model,EquipName from ConsumeApp ");
            strSql.Append(" where AppID=@AppID and ID=@ID ");
            SqlParameter[] parameters = {
                    new SqlParameter("@AppID", SqlDbType.Int,4),
                    new SqlParameter("@ID", SqlDbType.Int,4)};
            parameters[0].Value = AppID;
            parameters[1].Value = ID;

            LabMS.Model.ConsumeApp model=new LabMS.Model.ConsumeApp();
            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());
                }
                if(ds.Tables[0].Rows[0]["AppID"].ToString()!="")
                {
                    model.AppID=int.Parse(ds.Tables[0].Rows[0]["AppID"].ToString());
                }
                model.EquipType=ds.Tables[0].Rows[0]["EquipType"].ToString();
                if(ds.Tables[0].Rows[0]["EquipNum"].ToString()!="")
                {
                    model.EquipNum=int.Parse(ds.Tables[0].Rows[0]["EquipNum"].ToString());
                }
                if(ds.Tables[0].Rows[0]["UnitPrice"].ToString()!="")
                {
                    model.UnitPrice=decimal.Parse(ds.Tables[0].Rows[0]["UnitPrice"].ToString());
                }
                model.Argument=ds.Tables[0].Rows[0]["Argument"].ToString();
                model.Factory=ds.Tables[0].Rows[0]["Factory"].ToString();
                model.Model=ds.Tables[0].Rows[0]["Model"].ToString();
                model.EquipName=ds.Tables[0].Rows[0]["EquipName"].ToString();
                return model;
            }
            else
            {
                return null;
            }
        }