예제 #1
0
파일: Form1.cs 프로젝트: vinaytkere/TsExp
        public Form1()
        {
            InitializeComponent();

            var cont = new DemoDBEntities();
            var res  = cont.TimeSheets.ToList();



            gridControl1.DataSource = res.OrderBy(x => Convert.ToDateTime(x.Date));

            gridView1.Columns[1].Caption = "EmpID";
            gridView1.Columns[3].Caption = "Reporting Manager";
            gridView1.Columns[6].Caption = "JobID";
            gridView1.Columns[9].Caption = "No of Hours";

            gridView1.RowUpdated += GridView1_RowUpdated;

            gridView1.RowCellStyle += GridView1_RowCellStyle;
        }
예제 #2
0
파일: Form1.cs 프로젝트: vinaytkere/TsExp
        private void Form1_Load(object sender, EventArgs e)
        {
            comboBox1.SelectedIndex = 0;

            ac();
            var cont = new DemoDBEntities();
            var res  = cont.TimeSheets.ToList();

            if (comboBox1.SelectedIndex == 0)
            {
                gridControl1.DataSource = res.Where(x => Convert.ToDateTime(x.Date).Month == DateTime.Now.Month).OrderBy(x => Convert.ToDateTime(x.Date));
            }
            else
            {
                gridControl1.DataSource = res.Where(x => Convert.ToDateTime(x.Date).ToString("MM") == DateTime.Now.AddMonths(-1).ToString("MM")).OrderBy(x => Convert.ToDateTime(x.Date));
            }

            gridControl1.LookAndFeel.Style = DevExpress.LookAndFeel.LookAndFeelStyle.Flat;
            gridControl1.LookAndFeel.UseDefaultLookAndFeel        = false; // <<<<<<<<
            gridView1.Appearance.HeaderPanel.Options.UseBackColor = true;
            gridView1.Appearance.HeaderPanel.BackColor            = System.Drawing.Color.BurlyWood;
        }
예제 #3
0
파일: Form1.cs 프로젝트: vinaytkere/TsExp
        private void btnInsert_Click(object sender, EventArgs e)
        {
            var date = "";
            var com  = comboBox1.SelectedIndex;

            if (txtDate.Text != "")
            {
                date = Convert.ToDateTime(txtDate.Text).ToString("dd-MMM-yyyy");
            }
            else
            {
                MessageBox.Show("Date enter mado gaandu");
            }

            if (txtTask.Text == "" || string.IsNullOrEmpty(txtTask.Text) || string.IsNullOrWhiteSpace(txtTask.Text))
            {
                MessageBox.Show("Task enter mado gaandu");
            }
            else if (txtTime.Text == "" || string.IsNullOrEmpty(txtTime.Text) || string.IsNullOrWhiteSpace(txtTime.Text))
            {
                MessageBox.Show("Time enter mado gaandu");
            }
            else if (txtClient.Text == "" || string.IsNullOrEmpty(txtClient.Text) || string.IsNullOrWhiteSpace(txtClient.Text))
            {
                MessageBox.Show("Client enter mado gaandu");
            }
            else if (txtJobId.Text == "" || string.IsNullOrEmpty(txtJobId.Text) || string.IsNullOrWhiteSpace(txtJobId.Text))
            {
                MessageBox.Show("Job id enter mado gaandu");
            }
            else
            {
                try
                {
                    var cont     = new DemoDBEntities();
                    var lastDate = cont.TimeSheets.Where(x => x.Id == cont.TimeSheets.Max(y => y.Id)).Select(x => x.Date).First();
                    var lh       = cont.TimeSheets.Where(x => x.Id == cont.TimeSheets.Max(y => y.Id)).Select(x => x.Client).First();
                    // &&
                    int?total = 0;
                    var check = "";
                    var ld    = Convert.ToDateTime(lastDate).ToString("dd-MMM-yyyy");
                    var ed    = Convert.ToDateTime(txtDate.Text).ToString("dd-MMM-yyyy");
                    total = cont.TimeSheets.Where(x => x.Date == lastDate).Select(x => x.No_of_Hours).Sum();
                    if (ld == ed)
                    {
                        check = "";
                    }
                    else if ((lh.ToLower() == "holiday" || lh.ToLower() == "Leave"))
                    {
                        check = "";
                    }
                    else
                    {
                        check = total < 8 ? "Previous Day Total Time is less than 8 hours." : total > 8 ? "Previous Day Total Time is more than 8 hours." : "";
                    }

                    if (check != "")
                    {
                        MessageBox.Show(check);
                    }
                    else
                    {
                        var ts = new TimeSheet()
                        {
                            Date              = date,
                            EmpId             = txtEmpId.Text,
                            Name              = txtName.Text,
                            Reporting_Manager = txtRepMan.Text,
                            Product           = txtProduct.Text,
                            Client            = txtClient.Text,
                            JobID             = txtJobId.Text,
                            Project           = txtProject.Text,
                            Tasks             = txtTask.Text.Trim(),
                            No_of_Hours       = Convert.ToInt32(txtTime.Text)
                        };

                        cont.TimeSheets.Add(ts);
                        cont.SaveChanges();
                        var res = cont.TimeSheets.ToList();
                        gridControl1.DataSource = res.Where(x => Convert.ToDateTime(x.Date).Month == DateTime.Now.Month).OrderBy(x => Convert.ToDateTime(x.Date));;
                        txtDate.Text            = "";
                        txtClient.Clear();
                        txtTask.Clear();
                        txtTime.Clear();
                    }

                    comboBox1.SelectedIndex = com;

                    //var cont = new DemoDBEntities();
                    var res1 = cont.TimeSheets.ToList();

                    if (comboBox1.SelectedIndex == 0)
                    {
                        gridControl1.DataSource = res1.Where(x => Convert.ToDateTime(x.Date).Month == DateTime.Now.Month).OrderBy(x => Convert.ToDateTime(x.Date));
                        txtDate.Text            = DateTime.Now.ToString();
                    }

                    else
                    {
                        gridControl1.DataSource = res1.Where(x => Convert.ToDateTime(x.Date).ToString("MM") == DateTime.Now.AddMonths(-1).ToString("MM")).OrderBy(x => Convert.ToDateTime(x.Date));
                        txtDate.Text            = DateTime.Now.AddMonths(-1).ToString();
                    }
                }
                catch (Exception ex)
                {
                    //MessageBox.Show(ex.Message);
                }
            }
        }