Пример #1
0
        /// <summary>
        /// 데이터 그리드, 데이터 테이블 맵핑
        /// </summary>
        /// <param name="yaer">선택년도</param>
        /// <param name="month">선택월</param>
        /// <returns></returns>
        public DataTable MappingDataTable(string yaer, string month)
        {
            SQLiteCommand     command;
            SQLiteDataAdapter adapter;
            DataTable         dataTable = new DataTable();
            DataSet           dataSet   = new DataSet();
            string            sql       = "where Date LIKE \"" + yaer + "-" + month.PadLeft(2, '0') + "-" + "%\" Order by Date";
            string            phone     = "";

            //사용자의 권한이 일반직원인지 확인
            if (MemberData.GetMemberData.AuthorityData.Authority == 3)
            {
                //자기자신의 핸드폰번호
                phone = MemberData.GetMemberData.Phone;
            }
            else
            {
                //선택된 콤보박스의 인덱스를 가져와서 콤보박스에 연결된 List에서 핸드폰번호를 가져옴
                int index = TransitionPage.wageManagement.cbName.SelectedIndex;
                phone = CommData.GetCommData().getLoginDataList()[index].Phone;
            }

            sqlliteManager.DBOpen();

            //DB에 핸드폰 번호와 sql 전달, 핸드폰 번호는 DB의 테이블명
            command = sqlliteManager.Select(phone + yaer, sql);
            adapter = new SQLiteDataAdapter(command);
            adapter.Fill(dataSet);
            dataTable = dataSet.Tables[0];

            int TotalWage = 0;

            if (dataTable.Rows.Count != 0)
            {
                foreach (DataRow row in dataTable.Rows)
                {
                    if (!row["TotalWage"].ToString().Equals(""))
                    {
                        TotalWage += Convert.ToInt32(row["TotalWage"]);
                    }
                }
            }

            try
            {
                DataRow datarow = dataTable.NewRow();
                datarow["NightWage"] = "합계";
                datarow["TotalWage"] = TotalWage;

                dataTable.Rows.Add(datarow);
            }
            catch (Exception e)
            {
                Console.WriteLine("MappingDataTable : " + e.Message);
            }

            sqlliteManager.DBClose();

            return(dataTable);
        }
Пример #2
0
        /// <summary>
        /// 데이터 테이블의 테이터 입력
        /// </summary>
        /// <param name="startDate">시작날짜</param>
        /// <param name="endDate">마지막날짜</param>
        /// <param name="phone"></param>
        /// <param name="task"></param>
        public void setDataTable(string startDate, string endDate, string phone, int task)
        {
            Dictionary <string, List <ScheduleData> > scheduleDatas = Select(SQLiteData.TableSchedule, startDate, endDate, phone);
            List <LoginData> loginDataList = CommData.GetCommData().getLoginDataList();

            //데이터 그리드와 데이터 테이블 바인딩
            for (int i = 0; i < loginDataList.Count; i++)
            {
                if ((!phone.Equals("")) && !loginDataList[i].Phone.Equals(phone))
                {
                    continue;
                }
                if (task == 1)
                {
                    if (loginDataList[i].Task != 0 && loginDataList[i].Task != 1)
                    {
                        continue;
                    }
                }
                else if (task == 2)
                {
                    if (loginDataList[i].Task != 0 && loginDataList[i].Task != 2)
                    {
                        continue;
                    }
                }
                DataRow dataRow = dtSchedule.NewRow();
                dataRow["Name"]  = loginDataList[i].Name;
                dataRow["Phone"] = loginDataList[i].Phone;
                for (int j = 0; j < dateWeekList.Count; j++)
                {
                    dataRow[dateWeekList[j].date + "Date"]    = dateWeekList[j].date;
                    dataRow[dateWeekList[j].date + "OnTime"]  = "";
                    dataRow[dateWeekList[j].date + "OffTime"] = "";
                }

                dtSchedule.Rows.Add(dataRow);
            }

            ///데이터 입력
            foreach (DataRow data in dtSchedule.Rows)
            {
                if (scheduleDatas.ContainsKey(data["Phone"].ToString()))
                {
                    List <ScheduleData> scheduleLIst = new List <ScheduleData>();
                    scheduleDatas.TryGetValue(data["Phone"].ToString(), out scheduleLIst);
                    int j = 0;
                    for (int i = 0; (i < dateWeekList.Count && j < scheduleLIst.Count); i++)
                    {
                        if (data[dateWeekList[i].date + "Date"].Equals(scheduleLIst[j].Date))
                        {
                            data[dateWeekList[i].date + "OnTime"]  = scheduleLIst[j].OnTime;
                            data[dateWeekList[i].date + "OffTime"] = scheduleLIst[j].OffTime;
                            j++;
                        }
                    }
                }
            }
        }
        /// <summary>
        /// 이름 콤보박스 초기화
        /// </summary>
        private void inItcbName(int task)
        {
            List <LoginData> loginDataList = CommData.GetCommData().getLoginDataList();

            loginDataTaskList = new List <LoginData>();

            if (task == 0)
            {
                loginDataTaskList = loginDataList;
            }
            else if (task == 1)
            {
                for (int i = 0; i < loginDataList.Count; i++)
                {
                    if (loginDataList[i].Task == 0 || loginDataList[i].Task == 1)
                    {
                        loginDataTaskList.Add(loginDataList[i]);
                    }
                }
            }
            else if (task == 2)
            {
                for (int i = 0; i < loginDataList.Count; i++)
                {
                    if (loginDataList[i].Task == 0 || loginDataList[i].Task == 2)
                    {
                        loginDataTaskList.Add(loginDataList[i]);
                    }
                }
            }

            List <ComboBoxItem> NameItems = new List <ComboBoxItem>();

            NameItems.Add(new ComboBoxItem {
                Content = "전체"
            });

            foreach (LoginData data in loginDataTaskList)
            {
                ComboBoxItem item = new ComboBoxItem();
                item.Content = data.Name;
                NameItems.Add(item);
            }

            cbName.ItemsSource   = NameItems;
            cbName.SelectedIndex = 0;
            //콤보박스 인덱스를 자기자신으로 설정
            //현재 로그인된 사용자의 핸드폰번호로 loginDataList에서 검색해서 해당 객체를 가져온뒤 해당 객체가 몇번째 인덱스인지 검색
            //cbName.SelectedIndex = loginDataList.IndexOf(loginDataList.Find(x => x.Phone.Contains(MemberData.GetMemberData.Phone)));
        }
        //콤보박스 아이템 선택변환시
        private void cbName_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            CommData         commData      = CommData.GetCommData();
            List <LoginData> loginDataList = commData.getLoginDataList();

            if (cbName.SelectedIndex == -1)
            {
                tbPhone2.Text        = loginDataList[0].Phone;
                cbName.SelectedIndex = 0;
            }
            else
            {
                tbPhone2.Text = loginDataList[cbName.SelectedIndex].Phone;
            }
        }
        /// <summary>
        /// 이름콤보박스 초기화
        /// </summary>
        public void InitNameComboBox()
        {
            List <LoginData> loginDataList = CommData.GetCommData().getLoginDataList();

            List <ComboBoxItem> NameItems = new List <ComboBoxItem>();

            foreach (LoginData data in loginDataList)
            {
                ComboBoxItem item = new ComboBoxItem();
                item.Content = data.Name;
                NameItems.Add(item);
            }

            cbName.ItemsSource = NameItems;
            //콤보박스 인덱스를 자기자신으로 설정
            //현재 로그인된 사용자의 핸드폰번호로 loginDataList에서 검색해서 해당 객체를 가져온뒤 해당 객체가 몇번째 인덱스인지 검색
            cbName.SelectedIndex = loginDataList.IndexOf(loginDataList.Find(x => x.Phone.Contains(MemberData.GetMemberData.Phone)));
        }
        /// <summary>
        /// 삭제관련 이름 콤보박스 초기화
        /// </summary>
        private void initCBSecession()
        {
            CommData            commData      = CommData.GetCommData();
            List <LoginData>    loginDataList = commData.getLoginDataList();
            List <ComboBoxItem> NameItems     = new List <ComboBoxItem>();

            commData.setLoginDataList();

            foreach (LoginData data in loginDataList)
            {
                ComboBoxItem item = new ComboBoxItem();
                item.Content = data.Name;
                NameItems.Add(item);
            }

            cbName.SelectedIndex = 0;
            cbName.ItemsSource   = NameItems;
        }
Пример #7
0
        /// <summary>
        /// 데이터베이스에서 데이터 삭제
        /// </summary>
        /// <param name="dataTable">변경된 데이터테이블</param>
        public void DeleteDataTable(DataTable dataTable)
        {
            //전달받은 데이터테이블중 삭제된 행을 새로운 데이터 테이블에 입력
            DataTable dtChanges = dataTable.GetChanges(DataRowState.Deleted);
            string    OnTime, OffTime;

            //테이블의 값이 있는지 확인
            if (dtChanges != null)
            {
                foreach (DataRow data in dtChanges.Rows)
                {
                    //변경된 데이터테이블의 값이 조건에 맞는지 확인
                    if ((!data["OnTime", DataRowVersion.Original].ToString().Contains(":") && data["OnTime", DataRowVersion.Original].ToString().Length != 4) || (!data["OffTime", DataRowVersion.Original].ToString().Contains(":") && data["OffTime", DataRowVersion.Original].ToString().Length != 4) ||
                        (data["OnTime", DataRowVersion.Original].ToString().Contains(":") && data["OnTime", DataRowVersion.Original].ToString().Length > 5) || (data["OffTime", DataRowVersion.Original].ToString().Contains(":") && data["OffTime", DataRowVersion.Original].ToString().Length > 5))
                    {
                        return;
                    }
                    else
                    {
                        string[] swap = SplitString(data["OnTime", DataRowVersion.Original].ToString(), ':');
                        int      Time, Minute;
                        Time   = Convert.ToInt32(swap[0]);
                        Minute = Convert.ToInt32(swap[1]);
                        OnTime = Time.ToString().PadLeft(2, '0') + ":" + Minute.ToString().PadLeft(2, '0');

                        if (Time < 0 || Time > 29 || Minute > 60 || Minute < 0)
                        {
                            return;
                        }

                        swap    = SplitString(data["OffTime", DataRowVersion.Original].ToString(), ':');
                        Time    = Convert.ToInt32(swap[0]);
                        Minute  = Convert.ToInt32(swap[1]);
                        OffTime = Time.ToString().PadLeft(2, '0') + ":" + Minute.ToString().PadLeft(2, '0');

                        if (Time < 0 || Time > 29 || Minute > 60 || Minute < 0)
                        {
                            return;
                        }
                    }

                    string phone = "";

                    //권한이 일반직원인지 확인
                    if (MemberData.GetMemberData.AuthorityData.Authority == 3)
                    {
                        phone = MemberData.GetMemberData.Phone;
                    }
                    else
                    {
                        int index = TransitionPage.wageManagement.cbName.SelectedIndex;
                        phone = CommData.GetCommData().getLoginDataList()[index].Phone;
                    }


                    WageData scheduleData = new WageData();

                    scheduleData.OnTime  = OnTime;
                    scheduleData.OffTime = OffTime;
                    scheduleData.Date    = data["Date", DataRowVersion.Original].ToString();

                    Delete(phone, scheduleData);
                    WageCalculation(phone, data["Date", DataRowVersion.Original].ToString());
                }
            }
        }