Esempio n. 1
0
        private void CreateTableRecord(string set_guid, string stage_guid, DateTime work_date, double work_fact)
        {
            clSet set = _listUserSets.Find(x => (x.SetGuid.Equals(set_guid)) && (x.StageGuid.Equals(stage_guid)));

            if (set == null)
            {
                return;
            }

            double day_max_fact     = 15;
            double day_actualy_fact = 0;

            List <clTableRecord> _templist = _listUserTableRecords.FindAll(x => (x.WorkDate.ToShortDateString().Equals(work_date.ToShortDateString())));

            if ((_templist != null) && (_templist.Count > 0))
            {
                day_actualy_fact = _templist.Sum(x => x.WorkFact);
                if (work_fact > day_max_fact - day_actualy_fact)
                {
                    work_fact = day_max_fact - day_actualy_fact;
                }

                if (work_fact <= 0)
                {
                    MessageBox.Show("Количество отработанных часов в сутки должно быть меньше 15", "Превышен лимит", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    return;
                }
            }

            clTableRecord tr = new clTableRecord();

            tr.CreateDate   = DateTime.Now;
            tr.CreateUserId = this.UserId;

            tr.DeptId        = this.DepartmentId;
            tr.ExecutorId    = SelectedUserID;
            tr.ManuallyInput = 1;
            tr.ModifyDate    = DateTime.Now;
            tr.ModifyUserId  = this.SelectedUserID;
            tr.SetGuid       = set.SetGuid;
            tr.StageGuid     = set.StageGuid;

            tr.WorkDate = work_date;
            tr.WorkFact = work_fact;
            tr.WorkPlan = 0;

            _listUserTableRecords.Add(tr);
        }
Esempio n. 2
0
        public bool IsSetExists(string set_guid)
        {
            bool result = true;

            if (_listUserSets == null)
            {
                _listUserSets = new List <clSet>();
            }

            clSet set = _listUserSets.Find(x => (x.SetGuid.Equals(set_guid)));

            if (set == null)
            {
                result = false;
            }

            return(result);
        }
Esempio n. 3
0
        private void UpdateTableRecord(string set_guid, string stage_guid, DateTime work_date, double work_fact)
        {
            clSet set = _listUserSets.Find(x => (x.SetGuid.Equals(set_guid)));

            if (set == null)
            {
                return;
            }

            int tr_index = _listUserTableRecords.FindIndex(x =>
                                                           (x.SetGuid.Equals(set_guid)) &&
                                                           (x.StageGuid.Equals(stage_guid)) &&
                                                           (x.WorkDate.ToShortDateString().Equals(work_date.ToShortDateString()))
                                                           );
            double day_max_fact     = 15;
            double day_actualy_fact = 0;
            double day_free_fact    = 0;

            List <clTableRecord> _templist = _listUserTableRecords.FindAll(x => (x.WorkDate.ToShortDateString().Equals(work_date.ToShortDateString())));

            if ((_templist != null) && (_templist.Count > 0))
            {
                day_actualy_fact = _templist.Sum(x => x.WorkFact);
                day_free_fact    = day_max_fact - day_actualy_fact + _listUserTableRecords[tr_index].WorkFact;

                if (work_fact > day_free_fact)
                {
                    work_fact = day_free_fact;
                }

                if (day_free_fact <= 0)
                {
                    MessageBox.Show("Количество отработанных часов в сутки должно быть меньше 15", "Превышен лимит", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    return;
                }

                _listUserTableRecords[tr_index].WorkFact     = work_fact;
                _listUserTableRecords[tr_index].ModifyDate   = DateTime.Now;
                _listUserTableRecords[tr_index].ModifyUserId = this.UserId;
            }
        }
Esempio n. 4
0
        internal void ShowDialog(ref clSet set, string connString, clUser current_user)
        {
            set_guid   = set.SetGuid;
            stage_guid = set.StageGuid;
            conn       = connString;

            agreed_start = set.SetStart.ToShortDateString();
            agreed_end   = set.SetEnd.ToShortDateString();

            user             = current_user;
            lblContract.Text = set.Contract;
            lblStage.Text    = set.StageName;
            lblSetCode.Text  = set.SetCode;

            /*DateTime dt;
             * if (DateTime.TryParse(set.GipStart, out dt))
             *  gip_start = dt.ToShortDateString();
             * if (DateTime.TryParse(gip_end, out dt))
             *  gip_end = dt.ToShortDateString();*/

            lblGipStart.Text = set.GipStart.ToShortDateString();
            lblGipEnd.Text   = set.GipEnd.ToShortDateString();



            if (DateTime.TryParse(set.SetStart.ToShortDateString(), out set_start) && DateTime.TryParse(set.SetEnd.ToShortDateString(), out set_end))
            {
                int days = (set_end - set_start).Days;
                set_start             = new DateTime(DateTime.Now.Year, DateTime.Now.AddMonths(1).Month, 1, 0, 0, 0);
                dtpNewStartDate.Value = set_start;
                set_start             = set_start.AddDays(days);
                dtpNewEndDate.Value   = set_start;
            }


            this.ShowDialog();
        }
Esempio n. 5
0
        public void LoadIndividualPlan(DateTime PlanDate)
        {
            DateTime from = new DateTime(PlanDate.Year, PlanDate.Month, 1, 0, 0, 0);
            DateTime to   = new DateTime(PlanDate.Year, PlanDate.Month, DateTime.DaysInMonth(PlanDate.Year, PlanDate.Month), 0, 0, 0);

            //skud.LoadData(from.ToShortDateString(), to.ToShortDateString());

            if (_listUserTableRecords == null)
            {
                _listUserTableRecords = new List <clTableRecord>();
            }
            else
            {
                _listUserTableRecords.Clear();
            }

            if (_listUserSets == null)
            {
                _listUserSets = new List <clSet>();
            }
            else
            {
                _listUserSets.Clear();
            }

            SqlConnection connection = null;
            SqlDataReader dr         = null;

            try
            {
                connection = new SqlConnection(this.ConnStringSprut);
                SqlCommand command = new SqlCommand("[dbo].[PL_GetUserPlan]", connection);
                command.CommandType = CommandType.StoredProcedure;
                command.Parameters.Add("@user_id", SqlDbType.BigInt).Value = this._selected_user_id;
                command.Parameters.Add("@year", SqlDbType.Int).Value       = PlanDate.Year;
                command.Parameters.Add("@month", SqlDbType.Int).Value      = PlanDate.Month;

                connection.Open();
                dr = command.ExecuteReader();

                if (dr.HasRows)
                {
                    while (dr.Read())
                    {
                        DateTime dt;
                        double   val = 0;

                        #region Считываем табельную запись
                        clTableRecord tr = new clTableRecord();
                        tr.SetGuid    = dr["set_guid"].ToString();
                        tr.StageGuid  = dr["stage_guid"].ToString();
                        tr.ExecutorId = dr["executor_id"].ToString();
                        if (DateTime.TryParse(dr["work_date"].ToString(), out dt))
                        {
                            tr.WorkDate = dt;
                        }
                        else
                        {
                            tr.WorkDate = DateTime.Now;
                        }

                        if (Double.TryParse(dr["work_plan"].ToString(), out val))
                        {
                            tr.WorkPlan = val;
                        }
                        else
                        {
                            tr.WorkPlan = 0;
                        }

                        if (Double.TryParse(dr["work_fact"].ToString(), out val))
                        {
                            tr.WorkFact = val;
                        }
                        else
                        {
                            tr.WorkFact = 0;
                        }

                        if (Double.TryParse(dr["manually_input"].ToString(), out val))
                        {
                            tr.ManuallyInput = val;
                        }
                        else
                        {
                            tr.ManuallyInput = 0;
                        }

                        tr.DeptId = dr["dept_id"].ToString();
                        if (DateTime.TryParse(dr["modify_date"].ToString(), out dt))
                        {
                            tr.ModifyDate = dt;
                        }
                        else
                        {
                            tr.ModifyDate = DateTime.Now;
                        }
                        tr.ModifyUserId = dr["modify_user_id"].ToString();
                        if (DateTime.TryParse(dr["create_date"].ToString(), out dt))
                        {
                            tr.CreateDate = dt;
                        }
                        else
                        {
                            tr.CreateDate = DateTime.Now;
                        }
                        tr.CreateUserId = dr["create_user_id"].ToString();
                        _listUserTableRecords.Add(tr);
                        #endregion


                        #region Считываем комплект
                        clSet set = new clSet();
                        set.Contract  = dr["contract"].ToString();
                        set.SetCode   = dr["set_code"].ToString();
                        set.SetName   = dr["set_name"].ToString();
                        set.StageName = dr["stage_name"].ToString();
                        set.StageGuid = dr["stage_guid"].ToString();
                        //set.Kks = dr["set_kks"].ToString();
                        set.Building = dr["building"].ToString();

                        if (DateTime.TryParse(dr["gip_start"].ToString(), out dt))
                        {
                            set.GipStart = dt;
                        }
                        else
                        {
                            set.GipStart = DateTime.Now;
                        }

                        if (DateTime.TryParse(dr["gip_end"].ToString(), out dt))
                        {
                            set.GipEnd = dt;
                        }
                        else
                        {
                            set.GipEnd = DateTime.Now;
                        }

                        set.SetGuid = dr["set_guid"].ToString();

                        var temp = _listUserSets.Find(x => (x.SetGuid.Equals(set.SetGuid)));
                        if (temp == null)
                        {
                            _listUserSets.Add(set);
                        }

                        #endregion
                    }
                }

                if (_listUserTableRecords_Original == null)
                {
                    _listUserTableRecords_Original = new List <clTableRecord>();
                }
                else
                {
                    _listUserTableRecords_Original.Clear();
                }

                foreach (var item in _listUserTableRecords)
                {
                    clTableRecord tr = new clTableRecord();

                    tr.CreateDate    = item.CreateDate;
                    tr.CreateUserId  = item.CreateUserId;
                    tr.DeptId        = item.DeptId;
                    tr.ExecutorId    = item.ExecutorId;
                    tr.ManuallyInput = item.ManuallyInput;
                    tr.ModifyDate    = item.ModifyDate;
                    tr.ModifyUserId  = item.ModifyUserId;
                    tr.SetGuid       = item.SetGuid;
                    tr.StageGuid     = item.StageGuid;
                    tr.WorkDate      = item.WorkDate;
                    tr.WorkFact      = item.WorkFact;
                    tr.WorkPlan      = item.WorkPlan;

                    _listUserTableRecords_Original.Add(tr);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Произошла ошибка при получении индивидуального плана сотрудника.\n" + ex.Message + "\n" + ex.StackTrace, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            finally
            {
                if (dr != null)
                {
                    dr.Close();
                }
                if (connection != null)
                {
                    connection.Close();
                }
            }

            FillTableIndividualPlan(PlanDate);
        }
Esempio n. 6
0
        public string AddSet(string set_guid, string stage_guid, string contract, string stage_name)
        {
            string result = "";

            try
            {
                using (SqlConnection con = new SqlConnection(this.ConnStringSprut))
                {
                    con.Open();

                    using (SqlCommand command = new SqlCommand("[dbo].[PL_GetSetFromTdms]", con))
                    {
                        command.CommandType = CommandType.StoredProcedure;
                        command.Parameters.Add("@set_guid", SqlDbType.NVarChar).Value = set_guid;
                        using (SqlDataReader dr = command.ExecuteReader())
                        {
                            if (dr.HasRows)
                            {
                                dr.Read();
                                clSet newSet = new clSet();

                                newSet.Contract  = contract;
                                newSet.StageName = stage_name;

                                //newSet.Kks = dr["kks"].ToString();
                                newSet.SetCode  = dr["set_code"].ToString();
                                newSet.Building = dr["building"].ToString();
                                newSet.SetName  = dr["set_name"].ToString();

                                DateTime dt;
                                if (DateTime.TryParse(dr["gip_start"].ToString(), out dt))
                                {
                                    newSet.GipStart = dt;
                                }
                                else
                                {
                                    newSet.GipStart = Convert.ToDateTime("1900-01-01");
                                }

                                if (DateTime.TryParse(dr["gip_end"].ToString(), out dt))
                                {
                                    newSet.GipEnd = dt;
                                }
                                else
                                {
                                    newSet.GipEnd = Convert.ToDateTime("1900-01-01");
                                };

                                newSet.SetGuid   = dr["set_guid"].ToString();
                                newSet.StageGuid = stage_guid;
                                //newSet.StatusFromTdms = dr["status_from_tdms"].ToString();


                                //Добавить новый комплект
                                //_listPlanSets.Add(newSet);
                                _listUserSets.Add(newSet);
                                result = newSet.SetCode;

                                //Обновить таблицу комплектов
                                //DepartmentPlan_AddSet(newSet);
                            }
                            else
                            {
                                result = "";
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message + "\n" + ex.StackTrace);
                result = "";
            }

            return(result);
        }