private void attach_T_SCHEDULE(T_SCHEDULE entity)
 {
     this.SendPropertyChanging();
     entity.M_User = this;
 }
 private void detach_T_SCHEDULE(T_SCHEDULE entity)
 {
     this.SendPropertyChanging();
     entity.M_User = null;
 }
 partial void DeleteT_SCHEDULE(T_SCHEDULE instance);
 partial void UpdateT_SCHEDULE(T_SCHEDULE instance);
 partial void InsertT_SCHEDULE(T_SCHEDULE instance);
 private void detach_T_SCHEDULE(T_SCHEDULE entity)
 {
     this.SendPropertyChanging();
     entity.M_TITLE_COLOR = null;
 }
Ejemplo n.º 7
0
        /**
         * 登録又は更新ボタン押下時
         **/
        protected void Insert_Click(object sender, EventArgs e)
        {
            StartTimeError.Text = "";
            EndTimeError.Text   = "";

            //SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["connection"].ToString());
            //SqlCommand cmd;
            //SqlDataAdapter adapter = new SqlDataAdapter();

            string buttonId    = ((Button)sender).ID;
            string id          = buttonId;
            int    startYear   = Convert.ToInt32(Request["startYear"]);
            int    startMonth  = Convert.ToInt32(Request["startMonth"]);
            int    startDay    = Convert.ToInt32(Request["startDay"]);
            int    startOclock = Convert.ToInt32(Request["startOclock"]);
            int    startMinute = Convert.ToInt32(Request["startMinute"]);

            int endYear   = int.Parse(Request["endYear"]);
            int endMonth  = int.Parse(Request["endMonth"]);
            int endDay    = int.Parse(Request["endDay"]);
            int endOclock = int.Parse(Request["endOclock"]);
            int endMinute = int.Parse(Request["endMinute"]);

            string title = Request["title"];

            if (title.Contains("'"))
            {
                title = Regex.Replace(title, "'", "''");
            }

            int titleColor = int.Parse(Request["titleColor"]);

            string description = Request["description"];

            if (description.Contains("'"))
            {
                description = Regex.Replace(description, "'", "''");
            }

            string note = Request["note"];

            if (note.Contains("'"))
            {
                note = Regex.Replace(note, "'", "''");
            }

            int insertOrUpdateUser = (int)Session["userId"];
            int editAuthority      = insertOrUpdateUser;

            if (startDay <= DateTime.DaysInMonth(startYear, startMonth) && endDay <= DateTime.DaysInMonth(endYear, endMonth))
            {
                //try
                //{
                DateTime startTime = new DateTime(startYear, startMonth, startDay, startOclock, startMinute, 00, 00);
                DateTime endTime   = new DateTime(endYear, endMonth, endDay, endOclock, endMinute, 00, 00);
                DateTime now       = DateTime.Now;

                //con.Open();
                //登録ボタン押下時
                if (buttonId == "Insert")
                {
                    var db = new DataClasses1DataContext(ConfigurationManager.ConnectionStrings["connection"].ToString());

                    T_SCHEDULE scedule = new T_SCHEDULE
                    {
                        START_TIMESTAMP = startTime,
                        END_TIMESTAMP   = endTime,
                        TITLE           = title,
                        TITLE_COLOR     = titleColor,
                        DESCRIPTION     = description,
                        NOTE            = note,
                        EDIT_AUTHORITY  = editAuthority,
                        RELEASE_FLG     = '0',
                        INSERT_DATE     = now,
                        INSERT_USER     = insertOrUpdateUser,
                        DELETE_FLG      = '0'
                    };

                    db.T_SCHEDULE.InsertOnSubmit(scedule);
                    try
                    {
                        db.SubmitChanges();
                        Server.Transfer("~/Views/SchedulingIsOk.aspx");
                    }
                    catch (Exception insertError)
                    {
                        InsertError.Text = "登録エラーが発生しました";
                        db.SubmitChanges();
                    }

                    ////INSERT SQL文
                    //string insertQuery = "INSERT INTO T_SCHEDULE (" +
                    //"START_TIMESTAMP, END_TIMESTAMP, TITLE, TITLE_COLOR, DESCRIPTION, NOTE, " +
                    //"EDIT_AUTHORITY, RELEASE_FLG, INSERT_DATE, INSERT_USER, DELETE_FLG " +
                    //")" +
                    //" VALUES (" +
                    //"'" + startTime + "', '" + endTime + "', '" + title + "', '" + titleColor + "', '" + description + "', '" + note + "', '" +
                    //editAuthority + "'," + "0, '" + now + "', '" + insertOrUpdateUser + "'," + "0" +
                    //");";

                    //cmd = new SqlCommand(insertQuery, con);


                    //adapter.InsertCommand = new SqlCommand(insertQuery, con);
                    ////sql実行
                    //adapter.InsertCommand.ExecuteNonQuery();
                    //cmd.Dispose();
                }
                //更新ボタン押下時
                else if (buttonId == "Update")
                {
                    Update_Click(startTime, endTime, title,
                                 titleColor, description, note, editAuthority);
                }
                //}
                //catch (Exception exception)
                //{
                //    Console.WriteLine(exception.Message);
                //    throw;
                //}
                //finally
                //{
                //    con.Close();
                //    Server.Transfer("~/Views/SchedulingIsOk.aspx");
                //}
            }
            else
            {
                //存在しない日付が選択された場合(EX.2月31日)
                if (DateTime.DaysInMonth(startYear, startMonth) < startDay)
                {
                    StartTimeError.Text = "[開始日]は存在しない日付です。正しい日付を入力してください。";
                }
                if (DateTime.DaysInMonth(endYear, endMonth) < endDay)
                {
                    EndTimeError.Text = "[終了日]は存在しない日付です。正しい日付を入力してください。";
                }
            }
        }