예제 #1
0
    protected void btnSave_Click(object sender, DirectEventArgs e)
    {
        bool isSuccess = false;
        int  prkey     = int.Parse("0" + hdf_PRKEY.Text);

        if (prkey != 0)
        {
            var item = new CongThucKhoanSanXuatControler().GetCongThucByPrKey(prkey);
            item.CongThuc      = txt_CongThuc.Text;
            item.DKSanLuongDen = decimal.Parse("0" + txt_DKSanLuongDen.Text);
            item.DKSanLuongTu  = decimal.Parse("0" + txt_DKSanLuongTu.Text);
            item.GhiChu        = txt_GhiChu.Text;
            item.MaDonVi       = hdfBoPhan.Text;
            item.TenCongThuc   = txt_TenCongThuc.Text;
            item.TrongSo       = decimal.Parse("0" + txt_TrongSo.Text.Replace(".", ","));
            new CongThucKhoanSanXuatControler().Update(item);
        }
        else
        {
            var item = new DAL.CongThucKhoanSanXuat()
            {
                CongThuc      = txt_CongThuc.Text,
                DKSanLuongDen = decimal.Parse("0" + txt_DKSanLuongDen.Text),
                DKSanLuongTu  = decimal.Parse("0" + txt_DKSanLuongTu.Text),
                GhiChu        = txt_GhiChu.Text,
                MaDonVi       = hdfBoPhan.Text,
                TenCongThuc   = txt_TenCongThuc.Text,
                TrongSo       = decimal.Parse("0" + txt_TrongSo.Text.Replace(".", ","))
            };
            new CongThucKhoanSanXuatControler().Insert(item);
        }
        Dialog.ShowNotification("Cập nhật thành công");
        //wdCongThucKhoanSanXuatEdit.Hide();
        grpCongThucLuongKhoan.GetGridPanel().Reload();
    }
예제 #2
0
    /// <summary>
    /// Quy trình tính lương khoán
    /// Input:  Tổng khối lượng sản phẩm (sản phẩm chính) /
    ///         Số giờ đăng ký làm
    ///     => Khối lượng sản phẩm / 1 giờ      So sánh với sản lượng quy định
    ///     => Trọng số (số tiền cho 1 tấn sản lượng) * Tổng khối lượng sản phẩm
    ///     => Tổng số tiền cả tổ được nhận / Số giờ cả tổ làm trong ngày
    ///     => Số tiền trung bình / 1 giờ làm việc
    ///     Số tiền trung bình * số giờ làm việc của từng công nhân
    ///     => Số tiền lương khoán
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void ThayDoi(object sender, DirectEventArgs e)
    {
        try
        {
            decimal luong          = decimal.Parse("0" + hdfQDLuong.Text.Replace(".", ""));
            string  maBoPhan       = hdfMaBoPhan.Text;
            string  congthucstring = "";
            // sản lượng của sản phẩm chính
            double spchinh = double.Parse("0" + txtSanPhamChinh.Text.Replace(".", ","));
            // sản lượng của sản phẩm phụ
            double spphu = double.Parse("0" + txtSanPhamPhu.Text.Replace(".", ","));
            // Số giờ tổ đăng ký làm việc
            double giodangky = double.Parse("0" + txtSoGioDangKy.Text.Replace(".", ","));
            if (giodangky == 0)
            {
                giodangky = 1;
            }
            // Số giờ thực tế công nhân làm việc
            double giothucte = double.Parse("0" + txtSoGioLamViec.Text.Replace(".", ","));
            // Số giờ cả tổ làm trong 1 ngày (tổng số giờ làm việc của công nhân trong tổ)
            double giocato = double.Parse("0" + txtSoGioCaTo.Text.Replace(".", ","));
            if (giothucte < 0)
            {
                return;
            }
            decimal sanLuong = (decimal)(spchinh / giodangky);

            //var congthuc = CongThucKhoanList.FirstOrDefault(p => p.MaDonVi == maBoPhan && p.DKSanLuongTu <= (spchinh / giodangky) && p.DKSanLuongDen >= (spchinh / giodangky));
            DAL.CongThucKhoanSanXuat congthuc = new CongThucKhoanSanXuatControler().GetByMaBoPhanVaSanLuong(maBoPhan, sanLuong);
            if (congthuc == null)
            {
                Dialog.ShowError("Không tìm thấy công thức tính lương cho mã bộ phận: " + maBoPhan);
                return;
            }
            congthucstring = congthuc.CongThuc;
            // lấy công chuẩn
            double congchuan = new ThietLapCaTheoBoPhanController().GetCongChuan(maBoPhan);
            congthucstring = congthucstring.Replace("Luong", luong.ToString())
                             .Replace("CongChuan", congchuan.ToString())
                             .Replace("SanPhamChinh", txtSanPhamChinh.Text)
                             .Replace("SanPhamPhu", txtSanPhamPhu.Text)
                             .Replace("SoGioDangKy", txtSoGioDangKy.Text)
                             .Replace("SoGioLamViec", txtSoGioLamViec.Text)
                             .Replace("TongGio", txtSoGioCaTo.Text)
                             .Replace("TrongSo", congthuc.TrongSo.ToString())
                             .Replace(",", ".")
                             .Replace("/0", "/1");
            //RM.RegisterClientScriptBlock("abdc", "  alert('"+congthucstring+"'); ");

            RM.RegisterClientScriptBlock("abc", " txtLuongSanPham.setValue(Math.round( eval('" + congthucstring + "')));if (!txtLuongSanPham.getValue()) {txtLuongSanPham.setValue(0);}");
            //Dialog.ShowNotification("Công thức: <b>" + congthuc.CongThuc + " </b> <br/>    Trọng số: <b>"
            //    + congthuc.TrongSo.ToString() + " </b> <br/> Giá trị : <b>" + congthucstring);
        }
        catch (Exception ex)
        {
        }
    }
예제 #3
0
    protected void btnEditCongThucLuong_Click(object sender, DirectEventArgs e)
    {
        hdf_PRKEY.Text = grpCongThucLuongKhoan.GetSelectedRecordIDs().FirstOrDefault();
        var congthuc = new CongThucKhoanSanXuatControler().GetCongThucByPrKey(int.Parse("0" + hdf_PRKEY.Text));

        //cbb_MaCa.SetValue(congthuc.MaCa);
        hdfBoPhan.SetValue(congthuc.MaDonVi);
        DAL.DM_DONVI dv = new DM_DONVIController().GetById(congthuc.MaDonVi);
        if (dv != null)
        {
            cbx_bophan.Text = dv.TEN_DONVI;
        }
        txt_TenCongThuc.Text   = congthuc.TenCongThuc;
        txt_DKSanLuongTu.Text  = congthuc.DKSanLuongTu.ToString();
        txt_CongThuc.Text      = congthuc.CongThuc;
        txt_DKSanLuongDen.Text = congthuc.DKSanLuongDen.ToString();
        txt_TrongSo.SetValue(congthuc.TrongSo);
        txt_GhiChu.Text = congthuc.GhiChu;
        wdCongThucKhoanSanXuatEdit.Title = "Sửa công thức";
        wdCongThucKhoanSanXuatEdit.Icon  = Icon.Pencil;
        wdCongThucKhoanSanXuatEdit.Show();
    }
예제 #4
0
    protected void ImportDataFromExcel(object sender, DirectEventArgs e)
    {
        try
        {
            int    manv = 0, ngayindex = 3, sogiodk = 4, sogiolv = 5, giocato = 6, sospc = 7, sospp = 8, luongcn = 9, luongk = 10, luonght = 11;
            string extension = System.IO.Path.GetExtension(FileUploadField1.PostedFile.FileName).ToLower();
            TinhLuongKhoanController controller = new TinhLuongKhoanController();
            if (!extension.Equals(".xls") && !extension.Equals(".xlsx"))
            {
                X.Msg.Alert("Thông báo", "File bạn chọn không phải excel").Show();
                return;
            }
            string     fn           = System.IO.Path.GetFileName(FileUploadField1.PostedFile.FileName);
            string     saveLocation = Server.MapPath("File") + "\\" + fn;
            List <Row> dataExcel    = ExcelEngine.GetInstance().GetDataFromExcel(saveLocation, cbSheetName.SelectedItem.Value, 0);
            int        count        = 0;
            int        thang        = int.Parse(cbxMonth.SelectedItem.Value);
            int        nam          = int.Parse("0" + spnYear.Text);
            FileInfo   file;
            foreach (Row item in dataExcel)
            {
                try
                {
                    if (count > 20)
                    {
                        break;
                    }
                    if (string.IsNullOrEmpty(item[manv]))
                    {
                        count++;
                    }
                    else
                    {
                        count = 0;
                        DAL.ChamCongKhoanAustfeed chamCong = new DAL.ChamCongKhoanAustfeed();
                        chamCong.MaCB = item[manv].ToString();
                        string a = "";
                        if (chamCong.MaCB == "10699")
                        {
                            a = "";
                        }
                        float  luong    = 0;
                        string maBoPhan = string.Empty;
                        // lấy lương
                        DataTable table = DataController.DataHandler.GetInstance().ExecuteDataTable("TienLuong_LuongKhoan_GetInfoEmployeeByMaCB", "@MaCB", chamCong.MaCB);
                        if (table.Rows.Count > 0)
                        {
                            try { maBoPhan = table.Rows[0]["MA_DONVI"].ToString(); }
                            catch (Exception) { }
                            try { luong = float.Parse(table.Rows[0]["LuongCung"].ToString()); }
                            catch (Exception) { }
                        }
                        int ngay = int.Parse("0" + item[ngayindex].ToString());
                        chamCong.MonthYear = new DateTime(nam, thang, ngay);
                        try
                        {
                            chamCong.SoGioDangKy = double.Parse(item[sogiodk].ToString().Replace(".", ","));
                        }
                        catch (Exception) { }
                        try
                        {
                            chamCong.SoGioLamViec = double.Parse(item[sogiolv].ToString().Replace(".", ","));
                        }
                        catch (Exception) { }
                        try
                        {
                            chamCong.SoGioCaTo = double.Parse(item[giocato].ToString().Replace(".", ","));
                        }
                        catch (Exception) { }
                        try
                        {
                            chamCong.SanPhamChinh = decimal.Parse("0" + item[sospc].ToString().Replace(".", ","));
                        }
                        catch (Exception) { }
                        try
                        {
                            chamCong.SanPhamPhu = decimal.Parse("0" + item[sospp].ToString().Replace(".", ","));
                        }
                        catch (Exception) { }
                        chamCong.LuongCongNhat = decimal.Parse("0" + item[luongcn].ToString());
                        chamCong.LuongKhac     = decimal.Parse("0" + item[luongk].ToString());
                        chamCong.LuongHoTro    = double.Parse("0" + item[luonght].ToString());

                        if (chamCong.SoGioDangKy == 0)
                        {
                            chamCong.SoGioDangKy = 1;
                        }
                        if (chamCong.SoGioLamViec < 0)
                        {
                            continue;
                        }
                        decimal sanLuong                  = (decimal)((double)chamCong.SanPhamChinh / chamCong.SoGioDangKy);
                        string  congthucstring            = "";
                        DAL.CongThucKhoanSanXuat congthuc = new CongThucKhoanSanXuatControler().GetByMaBoPhanVaSanLuong(maBoPhan, sanLuong);
                        if (congthuc != null)
                        {
                            congthucstring = congthuc.CongThuc;
                        }
                        try
                        {
                            // lấy công chuẩn
                            double congchuan = new ThietLapCaTheoBoPhanController().GetCongChuan(maBoPhan);
                            congthucstring = congthucstring.Replace("Luong", luong.ToString())
                                             .Replace("CongChuan", congchuan.ToString())
                                             .Replace("SanPhamChinh", chamCong.SanPhamChinh.ToString())
                                             .Replace("SanPhamPhu", chamCong.SanPhamPhu.ToString())
                                             .Replace("TongGio", chamCong.SoGioCaTo.ToString())
                                             .Replace("SoGioDangKy", chamCong.SoGioDangKy.ToString())
                                             .Replace("SoGioLamViec", chamCong.SoGioLamViec.ToString())
                                             .Replace("TrongSo", congthuc.TrongSo.ToString())
                                             .Replace(",", ".")
                                             .Replace("/0", "/1");
                            string value = new DataTable().Compute(congthucstring, null).ToString();
                            chamCong.LuongSanPham = Math.Round(decimal.Parse(value), 0);
                        }
                        catch (Exception)
                        {
                            chamCong.LuongSanPham = 0;
                        }
                        DAL.ChamCongKhoanAustfeed temp = controller.GetByMaCanBoAndDay(chamCong.MaCB, ngay, thang, nam);
                        if (temp == null)
                        {
                            controller.Insert(chamCong);
                        }
                        else
                        {
                            controller.Update(chamCong);
                        }
                    }
                }
                catch (Exception ex)
                {
                    file = new FileInfo(saveLocation);
                    if (file.Exists)
                    {
                        file.Delete();
                    }
                }
            }
            file = new FileInfo(saveLocation);
            if (file.Exists)
            {
                file.Delete();
            }
            Dialog.ShowNotification("Nhập dữ liệu thành công");
            GridPanel1.Reload();
            wdNhapTuExcel.Hide();
        }
        catch (Exception ex)
        {
            Dialog.ShowError(ex.Message);
        }
    }