示例#1
0
        protected void btnUnSelect_Click(object sender, EventArgs e)
        {
            ArrayList rmList = new ArrayList();
            foreach (ListItem lstItem in lstSelectedYearMonth.Items)
            {
                if (lstItem.Selected)
                {
                    lstYearMonth.Items.Add(lstItem);
                    rmList.Add(lstItem);

                    string id = DbHelper.GetScalar("Select Id from BD_ParkingOffDays Where BuildingId = '" + Func.ParseString(Session["__BUILDINGID__"]) + "' and YearMonth = '" + drpYear.SelectedValue + drpMonth.SelectedValue + "' and OffDay = '" + lstItem.Value + "' and delflag = 0");
                    BD_ParkingOffDaysData data = new BD_ParkingOffDaysData();
                    ITransaction tran = factory.GetLoadObject(data, id);
                    Execute(tran);
                    if (!HasError)
                    {
                        //Get Data
                        data = (BD_ParkingOffDaysData)tran.Result;
                        data.DelFlag = "1";

                        data.ModifiedBy = Page.User.Identity.Name;
                        data.Modified = DateTime.Now.ToString("yyyyMMddHHmmss");

                        tran = factory.GetUpdateObject(data);

                        Execute(tran);

                        if (!HasError)
                        {
                        }
                        else
                        {
                        }
                    }
                }
            }
            //for (int i = 0; i < rmList.Count; i++)
            //{
            //    lstSelectedYearMonth.Items.Remove((ListItem)rmList[i]);
            //}
            ShowData();
        }
示例#2
0
        protected void btnCN_Click(object sender, EventArgs e)
        {
            Hashtable days = new Hashtable();
            days.Add("Sunday", "CN");
            days.Add("Monday", "T2");
            days.Add("Tuesday", "T3");
            days.Add("Wednesday", "T4");
            days.Add("Thursday", "T5");
            days.Add("Friday", "T6");
            days.Add("Saturday", "T7");

            Hashtable offDaysList = new Hashtable();
            DataSet ds = new DataSet();
            string sql = " SELECT OffDay";
            sql += " FROM BD_ParkingOffDays";
            sql += " WHERE BuildingId = '" + Func.ParseString(Session["__BUILDINGID__"]) + "' And YearMonth = '" + drpYear.SelectedValue + drpMonth.SelectedValue + "' and delFlag = 0";
            using (SqlDatabase db = new SqlDatabase())
            {
                using (SqlCommand cm = db.CreateCommand(sql))
                {
                    SqlDataAdapter da = new SqlDataAdapter(cm);
                    da.Fill(ds);

                    if (ds != null)
                    {
                        DataTable dt = ds.Tables[0];
                        foreach (DataRow rowType in dt.Rows)
                        {
                            string OffDay = rowType["OffDay"].ToString();
                            if (!offDaysList.ContainsKey(OffDay))
                            {
                                offDaysList.Add(OffDay, OffDay);
                            }
                        }
                    }
                }
            }

            DateTime firstDate = new DateTime(Func.ParseInt(drpYear.SelectedValue), Func.ParseInt(drpMonth.SelectedValue), 1);
            string tempDate = Func.ParseString(days[Func.ParseString(firstDate.DayOfWeek)]);
            if (tempDate == "CN" && !offDaysList.ContainsKey(firstDate.ToString("yyyyMMdd")))
            {
                BD_ParkingOffDaysData data = new BD_ParkingOffDaysData();
                ITransaction tran = factory.GetInsertObject(data);
                data.YearMonth = drpYear.SelectedValue + drpMonth.SelectedValue;
                data.ModifiedBy = Page.User.Identity.Name;
                data.CreatedBy = Page.User.Identity.Name;
                data.Created = DateTime.Now.ToString("yyyyMMddHHmmss");
                data.Modified = DateTime.Now.ToString("yyyyMMddHHmmss");
                data.DelFlag = "0";
                data.OffDay = firstDate.ToString("yyyyMMdd");

                data.BuildingId = Func.ParseString(Session["__BUILDINGID__"]);

                Execute(tran);

                if (!HasError)
                {
                    OperationLogger.WriteInfo(Constants.LogOperationAlbumId, Constants.LogActionInsertId, addSuccess, Page.User.Identity.Name);
                    mvMessage.SetCompleteMessage(addSuccess);
                }
                else
                {
                    OperationLogger.WriteError(Constants.LogOperationAlbumId, Constants.LogActionInsertId, addUnSuccess, Page.User.Identity.Name);
                    mvMessage.AddError(addUnSuccess);
                }
            }

            for (int i = 1; i < 31; i++)
            {
                DateTime tmp = firstDate.AddDays(i);
                if (!offDaysList.ContainsKey(tmp.ToString("yyyyMMdd")))
                {
                    if (tmp.Month == Func.ParseInt(drpMonth.SelectedValue))
                    {
                        string dayTmp = (Func.ParseString(days[Func.ParseString(tmp.DayOfWeek)]) != "" ? Func.ParseString(days[Func.ParseString(tmp.DayOfWeek)]) : tmp.DayOfWeek + "");
                        if (dayTmp == "CN")
                        {
                            BD_ParkingOffDaysData data = new BD_ParkingOffDaysData();
                            ITransaction tran = factory.GetInsertObject(data);
                            data.YearMonth = drpYear.SelectedValue + drpMonth.SelectedValue;
                            data.ModifiedBy = Page.User.Identity.Name;
                            data.CreatedBy = Page.User.Identity.Name;
                            data.Created = DateTime.Now.ToString("yyyyMMddHHmmss");
                            data.Modified = DateTime.Now.ToString("yyyyMMddHHmmss");
                            data.DelFlag = "0";
                            data.OffDay = tmp.ToString("yyyyMMdd");

                            data.BuildingId = Func.ParseString(Session["__BUILDINGID__"]);

                            Execute(tran);

                            if (!HasError)
                            {
                                OperationLogger.WriteInfo(Constants.LogOperationAlbumId, Constants.LogActionInsertId, addSuccess, Page.User.Identity.Name);
                                mvMessage.SetCompleteMessage(addSuccess);
                            }
                            else
                            {
                                OperationLogger.WriteError(Constants.LogOperationAlbumId, Constants.LogActionInsertId, addUnSuccess, Page.User.Identity.Name);
                                mvMessage.AddError(addUnSuccess);
                            }
                        }
                    }
                }
            }

            ShowData();
        }
示例#3
0
        protected void btnSelect_Click(object sender, EventArgs e)
        {
            ArrayList rmList = new ArrayList();
            using (SqlConnection rConn = new SqlConnection(Gnt.Configuration.ApplicationConfiguration.ConnectionString))
            {
                rConn.Open();
                foreach (ListItem lstItem in lstYearMonth.Items)
                {

                    if (lstItem.Selected)
                    {
                        lstSelectedYearMonth.Items.Add(lstItem);
                        rmList.Add(lstItem);

                        BD_ParkingOffDaysData data = new BD_ParkingOffDaysData();
                        ITransaction tran = factory.GetInsertObject(data);
                        data.YearMonth = drpYear.SelectedValue + drpMonth.SelectedValue;
                        data.ModifiedBy = Page.User.Identity.Name;
                        data.CreatedBy = Page.User.Identity.Name;
                        data.Created = DateTime.Now.ToString("yyyyMMddHHmmss");
                        data.Modified = DateTime.Now.ToString("yyyyMMddHHmmss");
                        data.DelFlag = "0";
                        data.OffDay = lstItem.Value;

                        data.BuildingId = Func.ParseString(Session["__BUILDINGID__"]);

                        Execute(tran);

                        if (!HasError)
                        {
                            OperationLogger.WriteInfo(Constants.LogOperationAlbumId, Constants.LogActionInsertId, addSuccess, Page.User.Identity.Name);
                            mvMessage.SetCompleteMessage(addSuccess);
                        }
                        else
                        {
                            OperationLogger.WriteError(Constants.LogOperationAlbumId, Constants.LogActionInsertId, addUnSuccess, Page.User.Identity.Name);
                            mvMessage.AddError(addUnSuccess);
                        }
                    }
                }
                rConn.Close();
            }
            //for (int i = 0; i < rmList.Count; i++)
            //{
            //    lstYearMonth.Items.Remove((ListItem)rmList[i]);
            //}
            ShowData();
        }