Example #1
0
        private void text_money_EditValueChanged(object sender, EventArgs e)
        {
            string  strGN = ((DevExpress.XtraEditors.TextEdit)sender).Text;
            decimal giaNhap;

            if (strGN.Equals(""))
            {
                giaNhap = 0;
            }
            else
            {
                giaNhap = Decimal.Parse(strGN);
            }
            CT_HoaDonNhap_View ct_hd = gridView1.GetFocusedRow() as CT_HoaDonNhap_View;

            foreach (CT_HoaDonNhap_View item in ls_cthd)
            {
                if (item.MaLinhKien.Equals(ct_hd.MaLinhKien))
                {
                    item.GiaNhap            = giaNhap;
                    item.ThanhTien          = item.SoLuong * item.GiaNhap;
                    gridControl1.DataSource = ls_cthd;
                    gridControl1.RefreshDataSource();
                    count_TongTien();
                    break;
                }
            }
        }
Example #2
0
        private void initVal(CT_HoaDonNhap_View cthd)
        {
            txt_MaLK.ReadOnly  = true;
            txt_TenLK.ReadOnly = true;
            txt_MaLK.Text      = cthd.MaLinhKien;
            txt_TenLK.Text     = cthd.TenLinhKien;

            DataTable dt = new DataTable();

            dt.Columns.Add("STT", typeof(int));
            dt.Columns.Add("SeriNumber", typeof(string));
            DataColumn col = new DataColumn("SeriNumber");

            for (int i = 0; i < cthd.SoLuong; i++)
            {
                if (cthd.SoSeri != null)
                {
                    if (i >= cthd.SoSeri.Count)
                    {
                        dt.Rows.Add(i, "");
                    }
                    else
                    {
                        dt.Rows.Add(i, cthd.SoSeri[i].ToString());
                    }
                }
                else
                {
                    dt.Rows.Add(i, "");
                }
            }
            gridControl1.DataSource = dt;
        }
Example #3
0
        //void text_money_Leave(object sender, EventArgs e)
        //{
        //    CT_HoaDonNhap_View lk = gridView1.GetFocusedRow() as CT_HoaDonNhap_View;
        //    var result = MessageBox.Show("Bạn có muốn lưu sự thay đổi xuống cơ sở dữ liệu hay không?", "Lưu thông tin", MessageBoxButtons.YesNo);
        //    if (result == DialogResult.Yes)
        //    { }
        //}


        void add_seriNumber_Click(object sender, EventArgs e)
        {
            CT_HoaDonNhap_View ct_hd = gridView1.GetFocusedRow() as CT_HoaDonNhap_View;

            using (var form = new Add_SeriNumber(ct_hd))
            {
                var result = form.ShowDialog();
                if (result == DialogResult.OK)
                {
                    ct_hd.SoSeri            = form.list_Seri;
                    gridControl1.DataSource = ls_cthd;
                    gridControl1.RefreshDataSource();
                }
            }
        }
Example #4
0
        private void RemoveRowGrid_CT_HoaDon()
        {
            CT_HoaDonNhap_View ct_hd = gridView1.GetFocusedRow() as CT_HoaDonNhap_View;

            foreach (CT_HoaDonNhap_View item in ls_cthd)
            {
                if (item.MaLinhKien.Equals(ct_hd.MaLinhKien))
                {
                    ls_cthd.Remove(item);
                    gridControl1.DataSource = ls_cthd;
                    gridControl1.RefreshDataSource();
                    break;
                }
            }
            count_TongTien();
        }
Example #5
0
        //thay doi so luong lk
        void repositoryItemSpinEdit1_EditValueChanged(object sender, EventArgs e)
        {
            decimal soluong = ((DevExpress.XtraEditors.SpinEdit)sender).Value;

            CT_HoaDonNhap_View ct_hd = gridView1.GetFocusedRow() as CT_HoaDonNhap_View;

            foreach (CT_HoaDonNhap_View item in ls_cthd)
            {
                if (item.MaLinhKien.Equals(ct_hd.MaLinhKien))
                {
                    item.SoLuong            = (Int32)soluong;
                    item.ThanhTien          = item.SoLuong * item.GiaNhap;
                    gridControl1.DataSource = ls_cthd;
                    gridControl1.RefreshDataSource();
                    count_TongTien();
                    break;
                }
            }
        }
Example #6
0
        private void addRowGrid_CT_HoaDon()
        {
            LinhKien_View lk   = gridViewLoc.GetFocusedRow() as LinhKien_View;
            bool          flat = false;

            if (ls_cthd.Count > 0)
            {
                int sl = 0;
                foreach (CT_HoaDonNhap_View item in ls_cthd)
                {
                    if (item.MaLinhKien.Equals(lk.MaLinhKien))
                    {
                        sl             = item.SoLuong + 1;
                        item.SoLuong   = sl;
                        item.ThanhTien = item.SoLuong * item.GiaNhap;
                        flat           = true;
                        break;
                    }
                }
            }

            if (!flat)
            {
                CT_HoaDonNhap_View ct_hd = new CT_HoaDonNhap_View();
                ct_hd.MaHoaDon    = txtMaPhieu.Text.Trim();
                ct_hd.MaLinhKien  = lk.MaLinhKien;
                ct_hd.TenLinhKien = lk.TenLinhKien;
                ct_hd.DonViTinh   = lk.TenDonViTinh;
                ct_hd.SoLuong     = 1;
                ct_hd.GiaNhap     = lk.GiaNhap;
                ct_hd.ThanhTien   = ct_hd.GiaNhap * ct_hd.SoLuong;
                ct_hd.TinhTrang   = 1;
                ls_cthd.Add(ct_hd);

                gridControl1.DataSource = ls_cthd;
            }

            gridControl1.RefreshDataSource();
            count_TongTien();
        }
Example #7
0
        public static List <CT_HoaDonNhap_View> readFile(string maHD, string fileName)
        {
            List <CT_HoaDonNhap_View> lst = new List <CT_HoaDonNhap_View>();

            // Reference to Excel Application.
            Excel.Application xlApp = new Excel.Application();

            // Open the Excel file.
            // You have pass the full path of the file.
            // In this case file is stored in the Bin/Debug application directory.
            Excel.Workbook xlWorkbook = xlApp.Workbooks.Open(Path.GetFullPath(fileName));

            // Get the first worksheet.
            Excel.Worksheet xlWorksheet = (Excel.Worksheet)xlWorkbook.Sheets.get_Item(1);

            // Get the range of cells which has data.
            Excel.Range xlRange = xlWorksheet.UsedRange;

            // Get an object array of all of the cells in the worksheet with their values.
            object[,] valueArray = (object[, ])xlRange.get_Value(
                Excel.XlRangeValueDataType.xlRangeValueDefault);

            CT_HoaDonNhap_View cthd = new CT_HoaDonNhap_View();

            bool ischange = true;

            // iterate through each cell and display the contents.
            for (int row = 2; row <= xlWorksheet.UsedRange.Rows.Count; ++row)
            {
                try
                {
                    if (ischange)
                    {
                        cthd             = new CT_HoaDonNhap_View();
                        cthd.MaLinhKien  = valueArray[row, 1].ToString().Trim();
                        cthd.TenLinhKien = valueArray[row, 2].ToString().Trim();
                        cthd.GiaNhap     = Decimal.Parse(valueArray[row, 3].ToString().Trim());
                        cthd.SoLuong     = Int32.Parse(valueArray[row, 4].ToString().Trim());
                        cthd.SoSeri      = new List <string>();
                        cthd.Thue        = 0;
                        cthd.ThanhTien   = (cthd.GiaNhap * cthd.SoLuong) + (cthd.GiaNhap * cthd.SoLuong) * (Decimal)(cthd.Thue / 100);
                        ischange         = false;
                    }
                    else
                    {
                        cthd.SoSeri.Add(valueArray[row, 5].ToString().Trim());
                        if (cthd.SoSeri.Count == cthd.SoLuong)
                        {
                            ischange = true;
                            lst.Add(cthd);
                        }
                    }
                }
                catch (Exception)
                {
                    MessageBox.Show("File dữ liệu không đúng định dạng hoặc dữ liệu bị sai, trùng. Xin vui lòng kiểm tra lại!");
                    return(new List <CT_HoaDonNhap_View>());
                }



                //var ct = lst.Where(key => key.MaLinhKien == maLK).FirstOrDefault();
                //if (ct != null)
                //{
                //    ct.SoLuong += 1;
                //    ct.ThanhTien = (ct.GiaNhap * ct.SoLuong) + (ct.GiaNhap * ct.SoLuong) * (Decimal)(ct.Thue / 100);
                //    ct.SoSeri.Add(seri);
                //}
                //else
                //{
                //    cthd = new CT_HoaDonNhap_View();
                //    cthd.MaHoaDon = maHD;
                //    cthd.SoLuong = 1;
                //    cthd.GiaNhap = giaNhap;
                //    cthd.MaLinhKien = maLK;
                //    LinhKien_View lk = LinhKien_DAL.get_LinhKien_ByMaLK(maLK);
                //    if(lk!= null)
                //        cthd.TenLinhKien = lk.TenLinhKien;
                //    cthd.Seri = seri;
                //    cthd.SoSeri = new List<string>();
                //    cthd.SoSeri.Add(seri);
                //    cthd.Thue = 0;
                //    cthd.ThanhTien = (cthd.GiaNhap * cthd.SoLuong) + (cthd.GiaNhap * cthd.SoLuong) * (Decimal)(cthd.Thue / 100);
                //    cthd.TinhTrang = 1;
                //    lst.Add(cthd);
                //}
            }

            // Close the Workbook.
            xlWorkbook.Close(false);

            // Relase COM Object by decrementing the reference count.
            Marshal.ReleaseComObject(xlWorkbook);

            // Close Excel application.
            xlApp.Quit();

            // Release COM object.
            Marshal.FinalReleaseComObject(xlApp);

            return(lst);
        }
Example #8
0
 public Add_SeriNumber(CT_HoaDonNhap_View cthd)
 {
     InitializeComponent();
     initVal(cthd);
 }