public Assetmoveplan CreateAssetmoveplan(Assetmoveplan info)
 {
     try
     {
         info.Planid = RetrieveSequenceValueOfCurrentTable();
         this.Database.AddInParameter(":Planid", info.Planid);//DBType:NUMBER
         this.Database.AddInParameter(":Assetparentcategoryid", info.Assetparentcategoryid);//DBType:VARCHAR2
         this.Database.AddInParameter(":Assetcategoryid", info.Assetcategoryid);//DBType:VARCHAR2
         this.Database.AddInParameter(":Storageflag", info.Storageflag);//DBType:NVARCHAR2
         this.Database.AddInParameter(":Storage", info.Storage);//DBType:NVARCHAR2
         this.Database.AddInParameter(":Plandatecycle", info.Plandatecycle);//DBType:VARCHAR2
         this.Database.AddInParameter(":Createddate", info.Createddate);//DBType:DATE
         this.Database.AddInParameter(":Startdate", info.Startdate);//DBType:DATE
         this.Database.AddInParameter(":Enddate", info.Enddate);//DBType:DATE
         this.Database.AddInParameter(":Plancategory", info.Plancategory);//DBType:NUMBER
         this.Database.AddInParameter(":Assetcount", info.Assetcount);//DBType:NUMBER
         string sqlCommand = @"INSERT INTO ""ASSETMOVEPLAN"" (""PLANID"",""ASSETPARENTCATEGORYID"",""ASSETCATEGORYID"",""STORAGEFLAG"",""STORAGE"",""PLANDATECYCLE"",""CREATEDDATE"",""STARTDATE"",""ENDDATE"",""PLANCATEGORY"",""ASSETCOUNT"") VALUES (:Planid,:Assetparentcategoryid,:Assetcategoryid,:Storageflag,:Storage,:Plandatecycle,:Createddate,:Startdate,:Enddate,:Plancategory,:Assetcount)";
         this.Database.ExecuteNonQuery(sqlCommand);
     }
     finally
     {
         this.Database.ClearParameter();
     }
     return info;
 }
        protected void LoadCurrentData()
        {
            #region Weekly
            var categories = AssetCategories.Where(p => string.IsNullOrEmpty(p.Assetparentcategoryid) || p.Assetparentcategoryid == Assetcategory.FixedAssetCategory).ToList();
            var weekData = AssetmoveplanService.RetrieveAssetmoveplanByCondition(WeeklyPlandatecycle,
                                                                               ucSelectStorageAddress.Storagetitle,
                                                                               ucSelectStorageAddress.StorageId);
            if (weekData.Count == 0)
            {
                foreach (var assetcategory in categories)
                {
                    var subCategories = AssetCategories.Where(p => p.Assetparentcategoryid == assetcategory.Assetcategoryid).ToList();
                    for (int i = 0; i < subCategories.Count; i++)
                    {
                        var currentSubCategory = subCategories[i];
                        var info = new Assetmoveplan();
                        info.Planid = i;//计划编号(时间段+分公司或项目体+分类ID等字符串的哈希值
                        info.Assetparentcategoryid = assetcategory.Assetcategoryid;//设备父类别
                        info.Assetparentcategoryname = assetcategory.Assetcategoryname;
                        info.Assetcategoryid = currentSubCategory.Assetcategoryid;//设备子类别
                        info.Assetsubcategoryname = currentSubCategory.Assetcategoryname;
                        info.Storageflag = ucSelectStorageAddress.Storagetitle;//分公司、项目体标识
                        info.Storage = ucSelectStorageAddress.StorageId;//分公司、项目体ID
                        info.Plandatecycle = WeeklyPlandatecycle;//时间段(如:周计划,20120723-20120729)
                        info.Createddate = DateTime.Now;//创建时间
                        info.Startdate = WeekFirstDate;//开始日期
                        info.Enddate = WeekLastDate;//结束日期
                        info.Plancategory = Assetrunplan.Weekly;//计划类别
                        info.Assetcount = 0;//计划设备数量
                        weekData.Add(info);
                    }
                }
            }
            rptWeeklyData.DataSource = weekData;
            rptWeeklyData.DataBind();
            // 合并单元格
            for (int i = rptWeeklyData.Items.Count - 1; i > 0; i--)
            {
                var previousCell = rptWeeklyData.Items[i - 1].FindControl("tdAssetparentcategoryname") as HtmlTableCell;
                var currentCell = rptWeeklyData.Items[i].FindControl("tdAssetparentcategoryname") as HtmlTableCell;
                currentCell.RowSpan = (currentCell.RowSpan == -1) ? 1 : currentCell.RowSpan;
                previousCell.RowSpan = (previousCell.RowSpan == -1) ? 1 : previousCell.RowSpan;
                if (currentCell.InnerText == previousCell.InnerText)
                {
                    currentCell.Visible = false;
                    previousCell.RowSpan += currentCell.RowSpan;
                }
            }
            #endregion

            #region Monthly
            var monthlyData = AssetmoveplanService.RetrieveAssetmoveplanByCondition(MonthlyPlandatecycle,
                                                                               ucSelectStorageAddress.Storagetitle,
                                                                               ucSelectStorageAddress.StorageId);
            if (monthlyData.Count == 0)
            {
                foreach (var assetcategory in categories)
                {
                    var subCategories = AssetCategories.Where(p => p.Assetparentcategoryid == assetcategory.Assetcategoryid).ToList();
                    for (int i = 0; i < subCategories.Count; i++)
                    {
                        var currentSubCategory = subCategories[i];
                        var info = new Assetmoveplan();
                        info.Planid = i;//计划编号(时间段+分公司或项目体+分类ID等字符串的哈希值)
                        info.Assetparentcategoryid = assetcategory.Assetcategoryid;//设备父类别
                        info.Assetparentcategoryname = assetcategory.Assetcategoryname;
                        info.Assetcategoryid = currentSubCategory.Assetcategoryid;//设备子类别
                        info.Assetsubcategoryname = currentSubCategory.Assetcategoryname;
                        info.Storageflag = ucSelectStorageAddress.Storagetitle;//分公司、项目体标识
                        info.Storage = ucSelectStorageAddress.StorageId;//分公司、项目体ID
                        info.Plandatecycle = MonthlyPlandatecycle;//时间段(如:周计划,20120723-20120729)
                        info.Createddate = DateTime.Now;//创建时间
                        info.Startdate = MonthFirstDate;//开始日期
                        info.Enddate = MonthLastDate;//结束日期
                        info.Plancategory = Assetrunplan.Monthly;//计划类别
                        info.Assetcount = 0;//计划设备数量
                        monthlyData.Add(info);
                    }
                }
            }
            rptMonthlyData.DataSource = monthlyData;
            rptMonthlyData.DataBind();
            // 合并单元格
            for (int i = rptMonthlyData.Items.Count - 1; i > 0; i--)
            {
                var previousCell = rptMonthlyData.Items[i - 1].FindControl("tdAssetparentcategoryname") as HtmlTableCell;
                var currentCell = rptMonthlyData.Items[i].FindControl("tdAssetparentcategoryname") as HtmlTableCell;
                currentCell.RowSpan = (currentCell.RowSpan == -1) ? 1 : currentCell.RowSpan;
                previousCell.RowSpan = (previousCell.RowSpan == -1) ? 1 : previousCell.RowSpan;
                if (currentCell.InnerText == previousCell.InnerText)
                {
                    currentCell.Visible = false;
                    previousCell.RowSpan += currentCell.RowSpan;
                }
            }
            #endregion
        }
 protected void BtnSave_Click(object sender, EventArgs e)
 {
     var list = new List<Assetmoveplan>();
     for (int i = 0; i < rptWeeklyData.Items.Count; i++)
     {
         var rowItem = rptWeeklyData.Items[i];
         var hfAssetcategoryid = rowItem.FindControl("hfAssetcategoryid") as HiddenField;
         var currentCategoryId = hfAssetcategoryid.Value;
         var currentCategory = AssetCategories.Where(p => p.Assetcategoryid == currentCategoryId).FirstOrDefault();
         if (currentCategory != null)
         {
             var info = new Assetmoveplan();
             int planId = 0;
             var hfPlanid = rowItem.FindControl("hfPlanid") as HiddenField;
             if (int.TryParse(hfPlanid.Value, out planId))
             {
                 info.Planid = planId;//计划编号(时间段+分公司或项目体+分类ID等字符串的哈希值
             }
             info.Assetparentcategoryid = currentCategory.Assetparentcategoryid;//设备父类别
             info.Assetcategoryid = currentCategory.Assetcategoryid;//设备子类别
             info.Storageflag = ucSelectStorageAddress.Storagetitle;//分公司、项目体标识
             info.Storage = ucSelectStorageAddress.StorageId;//分公司、项目体ID
             info.Plandatecycle = WeeklyPlandatecycle;//时间段(如:周计划,20120723-20120729)
             info.Createddate = DateTime.Now;//创建时间
             info.Startdate = WeekFirstDate;//开始日期
             info.Enddate = WeekLastDate;//结束日期
             info.Plancategory = Assetrunplan.Weekly;//计划类别
             info.Assetcount = 0;//计划设备数量
             var txtPlanCount = rowItem.FindControl("txtPlanCount") as TextBox;
             int count = 0;
             if (int.TryParse(txtPlanCount.Text, out count))
             {
                 info.Assetcount = count;//计划设备数量
             }
             list.Add(info);
         }
     }
     AssetmoveplanService.SaveAssetmoveplan(list);
     list.Clear();
     for (int i = 0; i < rptMonthlyData.Items.Count; i++)
     {
         var rowItem = rptMonthlyData.Items[i];
         var hfAssetcategoryid = rowItem.FindControl("hfAssetcategoryid") as HiddenField;
         var currentCategoryId = hfAssetcategoryid.Value;
         var currentCategory = AssetCategories.Where(p => p.Assetcategoryid == currentCategoryId).FirstOrDefault();
         if (currentCategory != null)
         {
             var info = new Assetmoveplan();
             int planId = 0;
             var hfPlanid = rowItem.FindControl("hfPlanid") as HiddenField;
             if (int.TryParse(hfPlanid.Value, out planId))
             {
                 info.Planid = planId;//计划编号(时间段+分公司或项目体+分类ID等字符串的哈希值
             }
             info.Assetparentcategoryid = currentCategory.Assetparentcategoryid;//设备父类别
             info.Assetcategoryid = currentCategory.Assetcategoryid;//设备子类别
             info.Storageflag = ucSelectStorageAddress.Storagetitle;//分公司、项目体标识
             info.Storage = ucSelectStorageAddress.StorageId;//分公司、项目体ID
             info.Plandatecycle = MonthlyPlandatecycle;//时间段(如:周计划,20120723-20120729)
             info.Createddate = DateTime.Now;//创建时间
             info.Startdate = MonthFirstDate;//开始日期
             info.Enddate = MonthLastDate;//结束日期
             info.Plancategory = Assetrunplan.Monthly;//计划类别
             info.Assetcount = 0;//计划设备数量
             var txtPlanCount = rowItem.FindControl("txtPlanCount") as TextBox;
             int count = 0;
             if (int.TryParse(txtPlanCount.Text, out count))
             {
                 info.Assetcount = count;//计划设备数量
             }
             list.Add(info);
         }
     }
     AssetmoveplanService.SaveAssetmoveplan(list);
     UIHelper.Alert(this, "保存成功!");
     //ClientScript.RegisterStartupScript(this.GetType(), Guid.NewGuid().ToString("N"), " document.getElementById('weeklyPlanContent').style.display = 'none';", true);
     ClientScript.RegisterStartupScript(this.GetType(), Guid.NewGuid().ToString("N"), "tabChange('weeklyPlan','weeklyPlanContent','monthPlanContent');", true);
 }
 public Assetmoveplan UpdateAssetmoveplanByPlanid(Assetmoveplan info)
 {
     try
     {
         this.Database.AddInParameter(":Planid", info.Planid);//DBType:NUMBER
         this.Database.AddInParameter(":Assetparentcategoryid", info.Assetparentcategoryid);//DBType:VARCHAR2
         this.Database.AddInParameter(":Assetcategoryid", info.Assetcategoryid);//DBType:VARCHAR2
         this.Database.AddInParameter(":Storageflag", info.Storageflag);//DBType:NVARCHAR2
         this.Database.AddInParameter(":Storage", info.Storage);//DBType:NVARCHAR2
         this.Database.AddInParameter(":Plandatecycle", info.Plandatecycle);//DBType:VARCHAR2
         this.Database.AddInParameter(":Createddate", info.Createddate);//DBType:DATE
         this.Database.AddInParameter(":Startdate", info.Startdate);//DBType:DATE
         this.Database.AddInParameter(":Enddate", info.Enddate);//DBType:DATE
         this.Database.AddInParameter(":Plancategory", info.Plancategory);//DBType:NUMBER
         this.Database.AddInParameter(":Assetcount", info.Assetcount);//DBType:NUMBER
         string sqlCommand = @"UPDATE ""ASSETMOVEPLAN"" SET  ""ASSETPARENTCATEGORYID""=:Assetparentcategoryid , ""ASSETCATEGORYID""=:Assetcategoryid , ""STORAGEFLAG""=:Storageflag , ""STORAGE""=:Storage , ""PLANDATECYCLE""=:Plandatecycle , ""CREATEDDATE""=:Createddate , ""STARTDATE""=:Startdate , ""ENDDATE""=:Enddate , ""PLANCATEGORY""=:Plancategory , ""ASSETCOUNT""=:Assetcount WHERE  ""PLANID""=:Planid";
         this.Database.ExecuteNonQuery(sqlCommand);
     }
     finally
     {
         this.Database.ClearParameter();
     }
     return info;
 }