Beispiel #1
0
        void getSEDate(string WeekInfo)
        {
            string[] str = WeekInfo.Split(':');
            DateTime sta = TextUtils.ToDate1((str[1].Split('-')[0]).Trim());
            int      tj  = Convert.ToInt32(str[0].Substring(str[0].Length - 2, 2));

            gridColumn9.Caption  = "Thứ 2 (" + sta.ToString("dd/MM") + ")";
            gridColumn9.ToolTip  = sta.ToString("dd/MM/yyyy");
            gridColumn10.Caption = "Thứ 3 (" + sta.AddDays(1).ToString("dd/MM") + ")";
            gridColumn10.ToolTip = sta.AddDays(1).ToString("dd/MM/yyyy");
            gridColumn11.Caption = "Thứ 4 (" + sta.AddDays(2).ToString("dd/MM") + ")";
            gridColumn11.ToolTip = sta.AddDays(2).ToString("dd/MM/yyyy");
            gridColumn12.Caption = "Thứ 5 (" + sta.AddDays(3).ToString("dd/MM") + ")";
            gridColumn12.ToolTip = sta.AddDays(3).ToString("dd/MM/yyyy");

            gridColumn13.Caption = "Thứ 6 (" + sta.AddDays(4).ToString("dd/MM") + ")";
            gridColumn13.ToolTip = sta.AddDays(4).ToString("dd/MM/yyyy");

            gridColumn14.Caption  = "Thứ 7 (" + sta.AddDays(5).ToString("dd/MM") + ")";
            gridColumn14.ToolTip  = sta.AddDays(5).ToString("dd/MM/yyyy");
            gridColumn9.FieldName = sta.ToString("dd/MM/yyyy");
            //10.Caption = "Thứ 3 (" + sta.AddDays(1).ToString("dd/MM") + ")";
            gridColumn10.FieldName = sta.AddDays(1).ToString("dd/MM/yyyy");
            //11.Caption = "Thứ 4 (" + sta.AddDays(2).ToString("dd/MM") + ")";
            gridColumn11.FieldName = sta.AddDays(2).ToString("dd/MM/yyyy");
            //12.Caption = "Thứ 5 (" + sta.AddDays(3).ToString("dd/MM") + ")";
            gridColumn12.FieldName = sta.AddDays(3).ToString("dd/MM/yyyy");

            //13.Caption = "Thứ 6 (" + sta.AddDays(4).ToString("dd/MM") + ")";
            gridColumn13.FieldName = sta.AddDays(4).ToString("dd/MM/yyyy");

            //14.Caption = "Thứ 7 (" + sta.AddDays(5).ToString("dd/MM") + ")";
            gridColumn14.FieldName = sta.AddDays(5).ToString("dd/MM/yyyy");
            grdNhanVien.Refresh();
        }
Beispiel #2
0
        void getSEDate(string WeekInfo)
        {
            string[] str = WeekInfo.Split(':');
            DateTime sta = TextUtils.ToDate1((str[1].Split('-')[0]).Trim());

            //string end = (str[1].Split('-')[1]).Trim();

            //DateTime dd = TextUtils.ToDate(end);
            gridColumn25.Caption = "Thứ 2 (" + sta.ToString("dd/MM") + ")";

            gridColumn25.ToolTip = sta.ToString("dd/MM/yyyy");
            gridColumn26.Caption = "Thứ 3 (" + sta.AddDays(1).ToString("dd/MM") + ")";
            gridColumn26.ToolTip = sta.AddDays(1).ToString("dd/MM/yyyy");
            gridColumn27.Caption = "Thứ 4 (" + sta.AddDays(2).ToString("dd/MM") + ")";
            gridColumn27.ToolTip = sta.AddDays(2).ToString("dd/MM/yyyy");
            gridColumn28.Caption = "Thứ 5 (" + sta.AddDays(3).ToString("dd/MM") + ")";
            gridColumn28.ToolTip = sta.AddDays(3).ToString("dd/MM/yyyy");

            gridColumn29.Caption = "Thứ 6 (" + sta.AddDays(4).ToString("dd/MM") + ")";
            gridColumn29.ToolTip = sta.AddDays(4).ToString("dd/MM/yyyy");

            gridColumn30.Caption = "Thứ 7 (" + sta.AddDays(5).ToString("dd/MM") + ")";
            gridColumn30.ToolTip = sta.AddDays(5).ToString("dd/MM/yyyy");

            grdData.Refresh();
        }
Beispiel #3
0
        private void grvVT_CellValueChanged(object sender, DevExpress.XtraGrid.Views.Base.CellValueChangedEventArgs e)
        {
            int index = grvVT.FocusedRowHandle;

            if (e.Column == colMaTime)
            {
                DateTime dateP       = TextUtils.ToDate1(txtDateP.Text);
                int      dateCurrent = TextUtils.ToInt(grvVT.GetFocusedRowCellValue(colMaTime));
                DateTime dateVT      = DateTime.Now.AddDays(dateCurrent);
                if (dateVT.Date <= dateP.Date)
                {
                    grvVT.SetFocusedRowCellValue(colMaStatus, "Đạt");
                }
                else
                {
                    grvVT.SetFocusedRowCellValue(colMaStatus, "Không đạt");
                }
                grvVT.FocusedRowHandle = index + 1;
                txtDateM.Text          = TextUtils.ToDecimal(colMaTime.SummaryItem.SummaryValue).ToString("n0");
                grvVT.FocusedRowHandle = index;
            }

            if (e.Column == colMaQty)
            {
                decimal price        = TextUtils.ToDecimal(grvVT.GetFocusedRowCellValue(colMaPrice));
                decimal qty          = TextUtils.ToDecimal(grvVT.GetFocusedRowCellValue(colMaQty));
                decimal tonKho       = TextUtils.ToDecimal(grvVT.GetFocusedRowCellValue(colMaTonKho));
                int     deliveryTime = TextUtils.ToInt(grvVT.GetFocusedRowCellValue(colMaDeliveryTime));

                grvVT.SetFocusedRowCellValue(colMaTotal, (qty * price).ToString("n0"));

                grvVT.FocusedRowHandle = index + 1;
                txtTotalM.Text         = TextUtils.ToDecimal(colMaTotal.SummaryItem.SummaryValue).ToString("n0");
                grvVT.FocusedRowHandle = index;

                if (qty > tonKho)
                {
                    grvVT.SetRowCellValue(index, colMaTime, deliveryTime);
                }
                else
                {
                    grvVT.SetRowCellValue(index, colMaTime, 1);
                }
            }
        }
Beispiel #4
0
        void getSEDate(string WeekInfo)
        {
            string[] str = WeekInfo.Split(':');
            DateTime sta = TextUtils.ToDate1((str[1].Split('-')[0]).Trim());
            int      tj  = Convert.ToInt32(str[0].Substring(str[0].Length - 2, 2));

            gridBand1.Caption   = "Tuần: " + tj;
            gridBand2.Caption   = "Tuần: " + (tj + 1).ToString();
            gridColumn9.Caption = "Thứ 2 (" + sta.ToString("dd/MM") + ")";

            gridColumn9.ToolTip = sta.ToString("dd/MM/yyyy");
            NgayBD = TextUtils.ToDate1(gridColumn9.ToolTip);
            gridColumn10.Caption = "Thứ 3 (" + sta.AddDays(1).ToString("dd/MM") + ")";
            gridColumn10.ToolTip = sta.AddDays(1).ToString("dd/MM/yyyy");
            gridColumn11.Caption = "Thứ 4 (" + sta.AddDays(2).ToString("dd/MM") + ")";
            gridColumn11.ToolTip = sta.AddDays(2).ToString("dd/MM/yyyy");
            gridColumn12.Caption = "Thứ 5 (" + sta.AddDays(3).ToString("dd/MM") + ")";
            gridColumn12.ToolTip = sta.AddDays(3).ToString("dd/MM/yyyy");

            gridColumn13.Caption = "Thứ 6 (" + sta.AddDays(4).ToString("dd/MM") + ")";
            gridColumn13.ToolTip = sta.AddDays(4).ToString("dd/MM/yyyy");

            gridColumn14.Caption = "Thứ 7 (" + sta.AddDays(5).ToString("dd/MM") + ")";
            gridColumn14.ToolTip = sta.AddDays(5).ToString("dd/MM/yyyy");

            gridColumn15.Caption = "Thứ 2 (" + sta.AddDays(7).ToString("dd/MM") + ")";
            gridColumn15.ToolTip = sta.AddDays(7).ToString("dd/MM/yyyy");
            gridColumn16.Caption = "Thứ 3 (" + sta.AddDays(8).ToString("dd/MM") + ")";
            gridColumn16.ToolTip = sta.AddDays(8).ToString("dd/MM/yyyy");
            gridColumn17.Caption = "Thứ 4 (" + sta.AddDays(9).ToString("dd/MM") + ")";
            gridColumn17.ToolTip = sta.AddDays(9).ToString("dd/MM/yyyy");
            gridColumn18.Caption = "Thứ 5 (" + sta.AddDays(10).ToString("dd/MM") + ")";
            gridColumn18.ToolTip = sta.AddDays(10).ToString("dd/MM/yyyy");

            gridColumn19.Caption = "Thứ 6 (" + sta.AddDays(11).ToString("dd/MM") + ")";
            gridColumn19.ToolTip = sta.AddDays(11).ToString("dd/MM/yyyy");

            gridColumn20.Caption = "Thứ 7 (" + sta.AddDays(12).ToString("dd/MM") + ")";
            gridColumn20.ToolTip = sta.AddDays(12).ToString("dd/MM/yyyy");
            NgayKT = TextUtils.ToDate1(gridColumn20.ToolTip);

            gridControl1.Refresh();
        }
Beispiel #5
0
        private void btnAddModule_Click(object sender, EventArgs e)
        {
            frmListModules frm = new frmListModules();

            if (frm.ShowDialog() == DialogResult.OK)
            {
                using (WaitDialogForm fWait = new WaitDialogForm("Vui lòng chờ trong giây lát...", "Đang thêm module..."))
                {
                    foreach (DataRow r in frm.dtSeleted.Rows)
                    {
                        string code = TextUtils.ToString(r["Code"]);
                        if (code == "")
                        {
                            continue;
                        }
                        DataRow[] drs = _dtVT.Select("Code = '" + code + "'");
                        if (drs.Length > 0)
                        {
                            continue;
                        }

                        decimal price = TextUtils.GetPrice(code, true);

                        int deliveryTime = -1;
                        if (code.StartsWith("PCB."))
                        {
                            //string sqlM = "SELECT top 1 * FROM  vGetPriceOfPart with(nolock)"
                            //        + " WHERE Price > 1 AND replace(replace([PartsCode],'/','#'),')','#') = '"
                            //        + "TPAT." + code.Substring(4, 7) + "'"
                            //        + " ORDER BY DateAboutF DESC";
                            //DataTable dtPrice = LibQLSX.Select(sqlM);

                            string    sqlM    = "exec spGetPriceOfPart 'TPAT." + code.Substring(4, 7) + "'";
                            DataTable dtPrice = LibQLSX.Select(sqlM);

                            deliveryTime = TextUtils.ToInt(dtPrice.Rows[0]["DeliveryTime"]);
                        }

                        DataRow dr = _dtVT.NewRow();
                        dr["Code"]  = TextUtils.ToString(r["Code"]);
                        dr["Name"]  = TextUtils.ToString(r["Name"]);
                        dr["Hang"]  = TextUtils.ToString(r["Hang"]);
                        dr["Unit"]  = "Bộ";
                        dr["Price"] = price.ToString("n0");
                        dr["Total"] = price.ToString("n0");
                        dr["Qty"]   = 1;

                        if (deliveryTime != -1)
                        {
                            dr["Time"] = deliveryTime;

                            DateTime dateP       = TextUtils.ToDate1(txtDateP.Text);
                            int      dateCurrent = TextUtils.ToInt(dr["Time"]);
                            if (dateCurrent < 0)
                            {
                                dr["Status"] = "Không đạt";
                            }
                            else
                            {
                                DateTime dateVT = DateTime.Now.AddDays(dateCurrent);
                                if (dateVT.Date <= dateP.Date)
                                {
                                    dr["Status"] = "Đạt";
                                }
                                else
                                {
                                    dr["Status"] = "Không đạt";
                                }
                            }
                        }

                        _dtVT.Rows.Add(dr);
                    }

                    txtTotalM.Text = TextUtils.ToDecimal(colMaTotal.SummaryItem.SummaryValue).ToString("n0");
                }
            }
        }
Beispiel #6
0
        private void btnAddVT_Click(object sender, EventArgs e)
        {
            frmListMaterial frm = new frmListMaterial();

            if (frm.ShowDialog() == DialogResult.OK)
            {
                using (WaitDialogForm fWait = new WaitDialogForm("Vui lòng chờ trong giây lát...", "Đang thêm vật tư..."))
                {
                    foreach (DataRow r in frm.dtAll.Rows)
                    {
                        string code = TextUtils.ToString(r["Code"]);
                        if (code == "")
                        {
                            continue;
                        }
                        DataRow[] drs = _dtVT.Select("Code = '" + code + "'");
                        if (drs.Length > 0)
                        {
                            continue;
                        }
                        decimal tonKho = TextUtils.ToDecimal(r["TonKho"]);

                        //string sqlM = "SELECT top 1 * FROM  vGetPriceOfPart with(nolock)"
                        //                + " WHERE Price > 1 AND replace(replace([PartsCode],'/','#'),')','#') = '"
                        //                + code.Replace(" ", "").Replace("/", "#").Replace(")", "#") + "'"
                        //                + " ORDER BY DateAboutF DESC";
                        //DataTable dtPrice = LibQLSX.Select(sqlM);

                        string    sqlM    = "exec spGetPriceOfPart '" + code.Replace(" ", "").Replace("/", "#").Replace(")", "#") + "'";
                        DataTable dtPrice = LibQLSX.Select(sqlM);

                        DataRow dr = _dtVT.NewRow();
                        dr["Code"]         = r["Code"].ToString();
                        dr["Name"]         = r["Name"].ToString();
                        dr["Hang"]         = r["Hang"].ToString();
                        dr["Unit"]         = r["Unit"].ToString();
                        dr["TonKho"]       = tonKho;
                        dr["DeliveryTime"] = TextUtils.ToInt(dtPrice.Rows[0]["DeliveryTime"]);

                        if (dtPrice.Rows.Count > 0)
                        {
                            dr["Price"] = TextUtils.ToDecimal(dtPrice.Rows[0]["Price"]).ToString("n0");
                            if (tonKho >= 1)
                            {
                                dr["Time"] = 1;
                            }
                            else
                            {
                                dr["Time"] = TextUtils.ToInt(dtPrice.Rows[0]["DeliveryTime"]);
                            }

                            DateTime dateP       = TextUtils.ToDate1(txtDateP.Text);
                            int      dateCurrent = TextUtils.ToInt(dr["Time"]);
                            if (dateCurrent < 0)
                            {
                                dr["Description"] = "Chưa phát sinh mua bán";
                            }
                            else
                            {
                                DateTime dateVT = DateTime.Now.AddDays(dateCurrent);
                                if (dateVT.Date <= dateP.Date)
                                {
                                    dr["Status"] = "Đạt";
                                }
                                else
                                {
                                    dr["Status"] = "Không đạt";
                                }
                            }
                        }
                        else
                        {
                            dr["Price"]       = TextUtils.ToDecimal(r["Price"]).ToString("n0");
                            dr["Description"] = "Chưa phát sinh mua bán";
                        }
                        dr["Total"] = TextUtils.ToDecimal(dr["Price"]).ToString("n0");

                        dr["Qty"] = 1;
                        _dtVT.Rows.Add(dr);
                    }
                    txtTotalM.Text = TextUtils.ToDecimal(colMaTotal.SummaryItem.SummaryValue).ToString("n0");
                    txtDateM.Text  = TextUtils.ToDecimal(colMaTime.SummaryItem.SummaryValue).ToString("n0");
                }
            }
        }
Beispiel #7
0
        private void btnThongKe_Click(object sender, EventArgs e)
        {
            try
            {
                if (ckNgay.Checked)
                {
                    NgayBD = (dateTimePicker1.Value);
                    NgayKT = (dateTimePicker2.Value);
                }
                else
                {
                    NgayBD = TextUtils.ToDate1("01/01/1990 12:00:00 AM");
                    NgayKT = DateTime.Now.AddYears(1);
                }
                if (ckDuAn.Checked)
                {
                    DuAn = leDuAn.EditValue.ToString();
                }
                else
                {
                    DuAn = "";
                }
                if (cknhom.Checked)
                {
                    Nhom = leNhom.Text;
                }
                else
                {
                    Nhom = "";
                }
                if (ckNhanVien.Checked)
                {
                    NhanVien = leNhaVien.EditValue.ToString();
                }
                else
                {
                    NhanVien = "";
                }
                if (ckCongViecPhatSinh.Checked)
                {
                    CongViecPhatSinh = "Phát sinh";
                }
                else
                {
                    CongViecPhatSinh = "";
                }
                if (ckHangMuc.Checked)
                {
                    HangMuc = leHangMuc.Text;
                }
                else
                {
                    HangMuc = "";
                }
            }
            catch (Exception ex)
            {
                TextUtils.ShowError(ex.Message);
            }
            grvData.BestFitColumns();
            _paraName[0] = "@NgayBD"; _paraValue[0] = NgayBD;
            _paraName[1] = "@NgayKT"; _paraValue[1] = NgayKT;
            _paraName[2] = "@DuAn"; _paraValue[2] = DuAn;
            _paraName[3] = "@Nhom"; _paraValue[3] = Nhom;
            _paraName[4] = "@NhanVien"; _paraValue[4] = NhanVien;
            _paraName[5] = "@HangMuc"; _paraValue[5] = HangMuc;
            _paraName[6] = "@CongViecPhatSinh"; _paraValue[6] = CongViecPhatSinh;
            DataTable Source = ModulesBO.Instance.LoadDataFromSP("sp_ThongKe", "Source", _paraName, _paraValue);

            grdData.DataSource = Source;
        }
Beispiel #8
0
        private void btnExeclGroup_Click(object sender, EventArgs e)
        {
            if (grvYC.RowCount == 0)
            {
                return;
            }

            string path = "";

            bool isQtyTotal = false;

            FolderBrowserDialog fbd = new FolderBrowserDialog();

            if (fbd.ShowDialog() == DialogResult.OK)
            {
                path = fbd.SelectedPath;
            }
            else
            {
                return;
            }

            string filePath    = Application.StartupPath + "\\Templates\\PhongVT\\BaoCaoVatTuChamTienDo.xls";
            string currentPath = path + "\\BaoCaoVatTuChamTienDo-" + DateTime.Now.Day + "-" + DateTime.Now.Month + "-" +
                                 DateTime.Now.Year + ".xls";

            try
            {
                File.Copy(filePath, currentPath, true);
            }
            catch (Exception ex)
            {
                MessageBox.Show("Có lỗi khi tạo biểu mẫu!" + Environment.NewLine + ex.Message,
                                TextUtils.Caption, MessageBoxButtons.OK, MessageBoxIcon.Stop);
                return;
            }

            grvYC.ExpandAllGroups();

            using (WaitDialogForm fWait = new WaitDialogForm("Vui lòng chờ trong giây lát...", "Đang tạo biểu mẫu..."))
            {
                System.Threading.Thread.CurrentThread.CurrentCulture = new System.Globalization.CultureInfo("en-US");
                Excel.Application app       = default(Excel.Application);
                Excel.Workbook    workBoook = default(Excel.Workbook);
                Excel.Worksheet   workSheet = default(Excel.Worksheet);
                try
                {
                    app = new Excel.Application();
                    app.Workbooks.Open(currentPath);
                    workBoook = app.Workbooks[1];
                    workSheet = (Excel.Worksheet)workBoook.Worksheets[1];

                    for (int i = grvYC.RowCount - 1; i >= 0; i--)
                    {
                        string proposalCode = TextUtils.ToString(grvYC.GetRowCellValue(i, colCode));
                        if (proposalCode == "")
                        {
                            continue;
                        }
                        string sql =
                            "select *,DATEDIFF(day, DateAboutE, DateAboutF) as Period from [dbo].[vRequirePartFull_Order] " +
                            "where DATEDIFF(day, DateAboutE, DateAboutF) > 1 and ProposalCode ='" +
                            proposalCode + "'";
                        DataTable dt = LibQLSX.Select(sql);
                        for (int j = dt.Rows.Count - 1; j >= 0; j--)
                        {
                            string partsCode = TextUtils.ToString(dt.Rows[j]["PartsCode"]);
                            string partsName = TextUtils.ToString(dt.Rows[j]["PartsName"]);
                            string module    = TextUtils.ToString(dt.Rows[j]["ProjectModuleCode"]);
                            string sl        = TextUtils.ToString(dt.Rows[j]["TotalBuy"]);
                            string dateE     = TextUtils.ToDate1(dt.Rows[j]["DateAboutE"].ToString()).ToString("dd/MM/yyyy");
                            string dateF     = TextUtils.ToDate1(dt.Rows[j]["DateAboutF"].ToString()).ToString("dd/MM/yyyy");
                            string period    = TextUtils.ToString(dt.Rows[j]["Period"]);

                            workSheet.Cells[12, 1] = "";
                            workSheet.Cells[12, 2] = j + 1;
                            workSheet.Cells[12, 3] = partsCode;
                            workSheet.Cells[12, 4] = partsName;
                            workSheet.Cells[12, 5] = module;
                            workSheet.Cells[12, 6] = sl;
                            workSheet.Cells[12, 7] = dateE;
                            workSheet.Cells[12, 8] = dateF;
                            workSheet.Cells[12, 9] = period;

                            ((Excel.Range)workSheet.Rows[12]).Insert();
                        }

                        workSheet.Cells[12, 1] = i + 1;
                        workSheet.Cells[12, 2] = "";
                        workSheet.Cells[12, 3] = TextUtils.ToString(grvYC.GetRowCellValue(i, colCode));
                        workSheet.Cells[12, 4] = TextUtils.ToString(grvYC.GetRowCellValue(i, colUserName));
                        workSheet.Cells[12, 5] = TextUtils.ToString(grvYC.GetRowCellValue(i, colOrderCode));

                        ((Excel.Range)workSheet.Rows[12]).Font.Bold = true;
                        ((Excel.Range)workSheet.Rows[12]).Insert();
                    }
                    ((Excel.Range)workSheet.Rows[11]).Delete();
                    ((Excel.Range)workSheet.Rows[11]).Delete();
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }
                finally
                {
                    if (app != null)
                    {
                        app.ActiveWorkbook.Save();
                        app.Workbooks.Close();
                        app.Quit();
                    }
                }
                Process.Start(currentPath);
            }
        }