Пример #1
0
    /// <summary>
    /// 将数组转化为设备实体类。
    /// </summary>
    /// <param name="arrayLine"></param>
    /// <returns></returns>
    private Tiyi.JD.SQLServerDAL.Appliance ConvertToEntity(string[] arrayLine)
    {
        if (arrayLine == null || arrayLine.Count() < 17)
        {
            return(null);
        }

        Tiyi.JD.SQLServerDAL.Appliance app = new Tiyi.JD.SQLServerDAL.Appliance();
        app.OwnerDepName = arrayLine[0];
        app.Address      = arrayLine[1];
        app.AssetSN      = arrayLine[2];
        app.BigClass     = arrayLine[3];
        app.AppName      = arrayLine[3];
        app.AppType      = arrayLine[4];
        app.Model        = arrayLine[5];
        app.PowerCold    = arrayLine[6];
        app.PowerHot     = arrayLine[7];
        app.Power        = arrayLine[8];
        app.Factory      = arrayLine[9];
        app.FixedSN      = arrayLine[10];
        app.ProductSN    = arrayLine[11];

        DateTime productDate;
        bool     productDateResult = DateTime.TryParse(arrayLine[12], out productDate);

        if (productDateResult)
        {
            app.ProductDate = productDate;
        }

        DateTime installDate;
        bool     installDateResult = DateTime.TryParse(arrayLine[13], out installDate);

        if (installDateResult)
        {
            app.InstallationDate = installDate;
        }

        app.IsScrapped = false;
        app.IsUsing    = true;
        app.Remark     = arrayLine[16];

        return(app);
    }
Пример #2
0
    private void LoadAppInfo(Guid appId)
    {
        Tiyi.JD.SQLServerDAL.Appliance app = bll_appManage.GetAppliance(appId);
        if (app == null)
        {
            return;
        }

        ltlProductSN.Text = app.ProductSN;
        ltlApp.Text       = app.BigClass + " " + app.AppType;
        ltlModel.Text     = app.Model;
        ltlFactory.Text   = app.Factory;
        ltlFixedSN.Text   = app.FixedSN;
        if (app.ProductDate == null)
        {
            ltlInstallationDate.Text = "空";
        }
        else
        {
            ltlInstallationDate.Text = string.Format("{0:yyyy-MM-dd}", app.ProductDate);
        }
    }
Пример #3
0
    protected void btnUpload_Click(object sender, EventArgs e)
    {
        System.Web.HttpPostedFile file   = fileUpload1.PostedFile;
        System.IO.Stream          stream = file.InputStream;
        System.IO.StreamReader    reader = new System.IO.StreamReader(stream, System.Text.Encoding.Default);

        System.Text.StringBuilder sb = new System.Text.StringBuilder();
        string line       = string.Empty;
        int    lineNumber = 0;

        while (!reader.EndOfStream)
        {
            line = reader.ReadLine();

            lineNumber++;
            if (lineNumber == 1)
            {
                continue;
            }

            string[] arrayLine;
            arrayLine = line.Split(',');
            if (arrayLine == null || arrayLine.Count() < 2)
            {
                continue;
            }

            Tiyi.JD.SQLServerDAL.Appliance app = ConvertToEntity(arrayLine);
            bllApp.CreateApplianceNotSubmit(app);

            sb.AppendLine(line);
        }
        bllApp.SubmitChanges();

        Label1.Text = (lineNumber - 1).ToString();
    }
Пример #4
0
    protected void FormView1_ItemCommand(object sender, FormViewCommandEventArgs e)
    {
        if (e.CommandName == "ToEdit")
        {
            FormView1.ChangeMode(FormViewMode.Edit);
        }

        if (e.CommandName == "UpdateApp")
        {
            FormView formView = sender as FormView;
            Guid     appId    = Guid.Empty;
            Guid.TryParse(hfAppId.Value, out appId);

            Tiyi.JD.SQLServerDAL.Appliance app = bllApp.GetAppliance(appId);
            app.BigClass  = (formView.FindControl("tbBigClass") as TextBox).Text;
            app.AppType   = (formView.FindControl("tbAppType") as TextBox).Text;
            app.Model     = (formView.FindControl("tbModel") as TextBox).Text;
            app.PowerCold = (formView.FindControl("tbPowerCold") as TextBox).Text;
            app.PowerHot  = (formView.FindControl("tbPowerHot") as TextBox).Text;
            app.Power     = (formView.FindControl("tbPower") as TextBox).Text;
            app.Factory   = (formView.FindControl("tbFactory") as TextBox).Text;
            app.FixedSN   = (formView.FindControl("tbFixedSN") as TextBox).Text;

            string   productDateString = (formView.FindControl("tbProductDate") as TextBox).Text;
            DateTime productDate       = new DateTime();
            DateTime.TryParse(productDateString, out productDate);
            if (productDate.Year > 2000)
            {
                app.ProductDate = productDate;
            }

            app.OwnerDepName = (formView.FindControl("tbOwnerDepName") as TextBox).Text;
            app.AssetSN      = (formView.FindControl("tbAssetSN") as TextBox).Text;
            app.Address      = (formView.FindControl("tbAddress") as TextBox).Text;

            string   installDateString = (formView.FindControl("tbInstallationDate") as TextBox).Text;
            DateTime installDate       = new DateTime();
            DateTime.TryParse(installDateString, out installDate);
            if (installDate.Year > 2000)
            {
                app.InstallationDate = installDate;
            }

            string   scrapDateString = (formView.FindControl("tbScrapDate") as TextBox).Text;
            DateTime scrapDate       = new DateTime();
            DateTime.TryParse(scrapDateString, out scrapDate);
            if (scrapDate.Year > 2000)
            {
                app.ScrapDate = scrapDate;
            }

            app.Remark = (formView.FindControl("tbRemark") as TextBox).Text;

            bllApp.UpdateAppliance(app);

            FormView1.ChangeMode(FormViewMode.ReadOnly);
        }

        if (e.CommandName == "CancelUpdate")
        {
            FormView1.ChangeMode(FormViewMode.ReadOnly);
        }
    }