Exemplo n.º 1
0
 /// <summary>
 /// Select Bảng
 /// </summary>
 /// <returns></returns>
 public Entities.SoDuKho[] Select()
 {
     try
     {
         List <Entities.SoDuKho> L = new List <Entities.SoDuKho>();
         SqlCommand    cmd         = new SqlCommand("exec sp_SelectSoDuKhosAll", new Connection().openConnection());
         SqlDataReader dr          = cmd.ExecuteReader(CommandBehavior.CloseConnection);
         while (dr.Read())
         {
             Entities.SoDuKho sdk = new Entities.SoDuKho();
             sdk.MaSoDuKho     = dr["MaSoDuKho"].ToString();
             sdk.MaKho         = dr["MaKho"].ToString();
             sdk.MaHangHoa     = dr["MaHangHoa"].ToString();
             sdk.TenHangHoa    = dr["TenHangHoa"].ToString();
             sdk.SoDuDauKy     = Convert.ToInt32(dr["SoDuDauKy"].ToString());
             sdk.NgayKetChuyen = Convert.ToDateTime(dr["NgayKetChuyen"].ToString());
             sdk.SoDuCuoiKy    = Convert.ToInt32(dr["SoDuCuoiKy"].ToString());
             sdk.TrangThai     = Boolean.Parse(dr["TrangThai"].ToString());
             L.Add(sdk);
         }
         cmd.Connection.Dispose();
         //Giai phong bo nho
         return(L.ToArray());
     }
     catch { return(null); }
 }
Exemplo n.º 2
0
 private void dgvHienThi_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
 {
     if (e.RowIndex >= 0)
     {
         if (DoiTuong == "theo_HDNhap")
         {
             frmXuLy_DieuChuyenKhoNoiBo.maHDNhap = dgvHienThi.Rows[e.RowIndex].Cells[2].Value.ToString();
             this.Close();
         }
         else
         if (DoiTuong == "theo_Kho")
         {
             frmXuLy_DieuChuyenKhoNoiBo.ct = dgvHienThi.Rows[e.RowIndex];
             this.Close();
         }
         else
         if (DoiTuong == "HangHoa")
         {
             Entities.SoDuKho sdk = new Entities.SoDuKho();
             sdk.MaHangHoa        = dgvHienThi.Rows[e.RowIndex].Cells["MaHangHoa"].Value.ToString();
             frmSoDuKhoHang.sdkho = sdk;
             this.Close();
         }
     }
 }
Exemplo n.º 3
0
        public Entities.SoDuKho[] LaySoDuKhoTheoNgay(int thangKC, int namKC)
        {
            int count = 0;

            for (int i = 0; i < sdk.Length; i++)
            {
                if (sdk[i].NgayKetChuyen.Month == thangKC && sdk[i].NgayKetChuyen.Year == namKC)
                {
                    count++;
                }
            }
            Entities.SoDuKho[] sdk1 = new Entities.SoDuKho[count];
            count = 0;
            for (int i = 0; i < sdk.Length; i++)
            {
                if (sdk[i].NgayKetChuyen.Month == thangKC && sdk[i].NgayKetChuyen.Year == namKC)
                {
                    sdk1[count] = sdk[i];
                    count++;
                }
            }
            if (sdk1.Length == 0)
            {
                return(new Entities.SoDuKho[0]);
            }
            else
            {
                return(sdk1);
            }
        }
Exemplo n.º 4
0
 /// <summary>
 /// Insert Update Bảng
 /// </summary>
 ////public bool Update(Entities.SoDuKho pxh)
 ////{
 ////    try
 ////    {
 ////        bool kt = false;
 ////        sdk = new Constants.SoDuKho();
 ////        Sql = new Constants.Sql();
 ////        string sql = Sql.UpdateSoDuSoQuy;
 ////        Connection conn = new Connection();
 ////        SqlConnection cn = conn.openConnection();
 ////        SqlCommand cmd = new SqlCommand(sql, cn);
 ////        cmd.Parameters.Add(sdk.MaSoDuKho, SqlDbType.VarChar, 20).Value = pxh.MaSoDuSoQuy;
 ////        cmd.Parameters.Add(sdk.SoDuDauKy, SqlDbType.VarChar, 20).Value = pxh.SoDuDauKy;
 ////        int i = cmd.ExecuteNonQuery();
 ////        if (i == 1)
 ////            kt = true;
 ////        else
 ////            kt = false;
 ////        cmd.Connection.Dispose();
 ////        cn.Close();
 ////        conn.closeConnection();
 ////        cn = null;
 ////        conn = null;
 ////        return kt;
 ////    }
 ////    catch
 ////    {
 ////        return false;
 ////    }
 ////}
 /// <summary>
 /// Insert Update Bảng
 /// </summary>
 ////public bool UpdateTrangThai(Entities.SoDuKho pxh)
 ////{
 ////    try
 ////    {
 ////        if (pxh.SoDuKhoID == 0)
 ////        {
 ////            Entities.SoDuKho sdsq = new Entities.SoDuKho("",1, pxh.MaSoDuKho, 0, pxh.NgayKetChuyen, pxh.SoDuCuoiKy, true);
 ////            return Insert(sdsq);
 ////        }
 ////        bool kt = false;
 ////        sdk = new Constants.SoDuKho();
 ////        Sql = new Constants.Sql();
 ////        string sql = Sql.UpdateSoDuSoQuy;
 ////        Connection conn = new Connection();
 ////        SqlConnection cn = conn.openConnection();
 ////        SqlCommand cmd = new SqlCommand(sql, cn);
 ////        cmd.Parameters.Add(sdk.SoDuKhoID, SqlDbType.Int).Value = pxh.SoDuSoQuyID;
 ////        cmd.Parameters.Add(sdk.SoDuCuoiKy, SqlDbType.Float).Value = pxh.SoDuDauKy;
 ////        int i = cmd.ExecuteNonQuery();
 ////        if (i == 1)
 ////            kt = true;
 ////        else
 ////            kt = false;
 ////        cmd.Connection.Dispose();
 ////        cn.Close();
 ////        conn.closeConnection();
 ////        cn = null;
 ////        conn = null;
 ////        Insert(pxh);
 ////        return kt;
 ////    }
 ////    catch
 ////    {
 ////        return false;
 ////    }
 ////}
 //// <summary>
 //// Delete Bảng
 //// </summary>
 public bool Delete(Entities.SoDuKho pxh)
 {
     try
     {
         bool kt = false;
         sdk = new Constants.SoDuKho();
         Sql = new Constants.Sql();
         string        sql  = "exec sp_DeleteSoDuKho @MaSoDuKho";
         Connection    conn = new Connection();
         SqlConnection cn   = conn.openConnection();
         SqlCommand    cmd  = new SqlCommand(sql, cn);
         cmd.Parameters.Add(sdk.MaSoDuKho, SqlDbType.VarChar, 20).Value = pxh.MaSoDuKho;
         int i = cmd.ExecuteNonQuery();
         if (i >= 0)
         {
             kt = true;
         }
         else
         {
             kt = false;
         }
         cmd.Connection.Dispose();
         cn.Close();
         conn.closeConnection();
         cn   = null;
         conn = null;
         return(kt);
     }
     catch
     {
         return(false);
     }
 }
Exemplo n.º 5
0
        private void dgvsodukhohang_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
        {
            if (e.RowIndex > -1)
            {
                if (dgvsodukhohang.RowCount > 0)
                {
                    if (!(bool)dgvsodukhohang.Rows[0].Cells["TrangThai"].Value)
                    {
                        bool kt = true;
                        for (int i = 0; i < ddh.Length; i++)
                        {
                            if (ddh[i].NgayKetChuyen.Month == Convert.ToInt32(cbbthang.Text) - 1 && ddh[i].NgayKetChuyen.Year.ToString() == cbbnam.Text)
                            {
                                kt = false;
                                break;
                            }
                        }
                        if (kt)
                        {
                            string maSoDuKho = dgvsodukhohang.Rows[e.RowIndex].Cells["MaSoDuKho"].Value.ToString();
                            string maHangHoa = dgvsodukhohang.Rows[e.RowIndex].Cells["MaHangHoa"].Value.ToString();
                            string makho     = dgvsodukhohang.Rows[e.RowIndex].Cells["MaKho"].Value.ToString();

                            int sddk = Convert.ToInt32(dgvsodukhohang.Rows[e.RowIndex].Cells["SoDuDauKy"].Value.ToString());
                            cl          = new Server_Client.Client();
                            this.client = cl.Connect(Luu.IP, Luu.Ports);
                            Entities.SoDuKho sodukho = new Entities.SoDuKho("Delete", 1, maSoDuKho, makho, maHangHoa, sddk, 0, datesv, 0, 0, false);
                            clientstrem = cl.SerializeObj(this.client, "SoDuKho", sodukho);
                            bool msg = true;
                            msg = (bool)cl.DeserializeHepper(clientstrem, msg);
                            if (msg)
                            {
                                cl          = new Server_Client.Client();
                                this.client = cl.Connect(Luu.IP, Luu.Ports);
                                Entities.ChiTietKhoHangTheoHoaHonNhap[] ctkho = new Entities.ChiTietKhoHangTheoHoaHonNhap[1];
                                ctkho[0]           = new Entities.ChiTietKhoHangTheoHoaHonNhap();
                                ctkho[0].Hanhdong  = "Update";
                                ctkho[0].Makho     = makho;
                                ctkho[0].Mahanghoa = maHangHoa;
                                ctkho[0].Soluong   = sddk;
                                clientstrem        = cl.SerializeObj(this.client, "ThemChiTietKhoHang", ctkho);

                                tsslma.Text        = maHangHoa;
                                tsslsodudauky.Text = sddk.ToString();
                                tsslten.Text       = LayTenHangHoa(maHangHoa);
                                HienThi();
                            }
                            else
                            {
                                MessageBox.Show("Insert thất Bại");
                            }
                        }
                    }
                }
            }
        }
Exemplo n.º 6
0
 public void LaySoDuKho()
 {
     Entities.SoDuKho[] ddh = new Entities.SoDuKho[1];
     ddh = new BizLogic.SoDuKho().Select();
     if (ddh != null)
     {
         sdk = ddh;
     }
     else
     {
         sdk = new Entities.SoDuKho[0];
     }
 }
Exemplo n.º 7
0
        private void toolStripButton1_Click(object sender, EventArgs e)
        {
            bool kt1 = true;

            for (int i = 0; i < dgvsodukhohang.RowCount; i++)
            {
                if (dgvsodukhohang.Rows[i].Cells["MaHangHoa"].Value.ToString() == tsslma.Text)
                {
                    kt1 = false;
                    break;
                }
            }
            if (kt1)
            {
                string           ma    = LayID("SoDuKho");
                Entities.KhoHang kh    = (Entities.KhoHang)cbbkhohang.SelectedItem;
                string           makho = kh.MaKho;
                cl          = new Server_Client.Client();
                this.client = cl.Connect(Luu.IP, Luu.Ports);
                Entities.SoDuKho sodukho = new Entities.SoDuKho("Insert", 1, ma, makho, tsslma.Text, Convert.ToInt32(tsslsodudauky.Text), 0, datesv, 0, 0, false);
                clientstrem = cl.SerializeObj(this.client, "SoDuKho", sodukho);
                bool msg = true;
                msg = (bool)cl.DeserializeHepper(clientstrem, msg);
                if (msg)
                {
                    cl          = new Server_Client.Client();
                    this.client = cl.Connect(Luu.IP, Luu.Ports);
                    Entities.ChiTietKhoHangTheoHoaHonNhap[] ctkho = new Entities.ChiTietKhoHangTheoHoaHonNhap[1];
                    ctkho[0]           = new Entities.ChiTietKhoHangTheoHoaHonNhap();
                    ctkho[0].Hanhdong  = "UpdateCong";
                    ctkho[0].Makho     = makho;
                    ctkho[0].Mahanghoa = tsslma.Text;
                    ctkho[0].Soluong   = Convert.ToInt32(tsslsodudauky.Text);
                    clientstrem        = cl.SerializeObj(this.client, "ThemChiTietKhoHang", ctkho);
                    int i = 0;
                    i = (int)cl.DeserializeHepper(clientstrem, i);
                    HienThi();
                    tsslma.Text        = "<F4>-tra cứu";
                    tsslsodudauky.Text = "0";
                    tsslten.Text       = "";
                }
                else
                {
                    MessageBox.Show("Insert thất Bại");
                }
            }
            else
            {
                MessageBox.Show("Hàng Hóa đã được nhập số dư đầu kỳ - Không thể thêm mới");
            }
        }
Exemplo n.º 8
0
        public void LayChiTiet_HangHoaXuat()
        {
            try
            {
                cl          = new Server_Client.Client();
                this.client = cl.Connect(Luu.IP, Luu.Ports);
                Entities.ChiTietKhoHangTheoHoaHonNhap nv = new Entities.ChiTietKhoHangTheoHoaHonNhap("Select");
                clientstrem = cl.SerializeObj(this.client, "ChiTietKho", nv);
                Entities.ChiTietKhoHangTheoHoaHonNhap[] kh1 = new Entities.ChiTietKhoHangTheoHoaHonNhap[1];
                kh1 = (Entities.ChiTietKhoHangTheoHoaHonNhap[])cl.DeserializeHepper1(clientstrem, kh1);

                if (kh1 == null)
                {
                    ctHangHoaTheoKho = new Entities.ChiTietKhoHangTheoHoaHonNhap[0];
                    ctBCXH           = new Entities.SoDuKho[0];
                    return;
                }
                ctHangHoaTheoKho = kh1;

                ctBCXH = new Entities.SoDuKho[ctHangHoaTheoKho.Length];
                for (int i = 0; i < ctHangHoaTheoKho.Length; i++)
                {
                    ctBCXH[i]            = new Entities.SoDuKho();
                    ctBCXH[i].MaKho      = ctHangHoaTheoKho[i].Makho;
                    ctBCXH[i].MaHangHoa  = ctHangHoaTheoKho[i].Mahanghoa;
                    ctBCXH[i].SoDuDauKy  = 0;
                    ctBCXH[i].SoDuCuoiKy = 0;
                    ctBCXH[i].PhatSinhNo = 0;
                    ctBCXH[i].PhatSinhCo = 0;
                }
                Entities.SoDuKho[] sdk1 = LaySoDuKhoTheoNgay(Convert.ToInt32(cbbthang.Text), Convert.ToInt32(cbbnam.Text));
                for (int i = 0; i < sdk1.Length; i++)
                {
                    for (int j = 0; j < ctBCXH.Length; j++)
                    {
                        if (sdk1[i].MaKho == ctBCXH[j].MaKho && sdk1[i].MaHangHoa == ctBCXH[j].MaHangHoa)
                        {
                            ctBCXH[j].SoDuDauKy = sdk1[i].SoDuDauKy;
                        }
                    }
                }
            }
            catch
            {
            }
        }
 public void SoDuKho()
 {
     try
     {
         cl           = new Server_Client.Client();
         this.client1 = cl.Connect(Luu.IP, Luu.Ports);
         Entities.SoDuKho ctxh = new Entities.SoDuKho("Select");
         clientstrem = cl.SerializeObj(this.client1, "SoDuKho", ctxh);
         sodukho     = (Entities.SoDuKho[])cl.DeserializeHepper1(clientstrem, sodukho);
         if (sodukho == null)
         {
             sodukho = new Entities.SoDuKho[0];
             return;
         }
     }
     catch
     {
     }
 }
Exemplo n.º 10
0
 public void LaySoDuKho()
 {
     Entities.SoDuKho sodukho;
     sodukho     = new Entities.SoDuKho();
     cl          = new Server_Client.Client();
     this.client = cl.Connect(Luu.IP, Luu.Ports);
     sodukho     = new Entities.SoDuKho("Select");
     clientstrem = cl.SerializeObj(this.client, "SoDuKho", sodukho);
     ddh         = new Entities.SoDuKho[1];
     ddh         = (Entities.SoDuKho[])cl.DeserializeHepper(clientstrem, ddh);
     if (ddh != null)
     {
         sdk = ddh;
     }
     else
     {
         sdk = new Entities.SoDuKho[0];
     }
 }
Exemplo n.º 11
0
        public void HienThi()
        {
            List <Entities.SoDuKho> listTemp = new List <Entities.SoDuKho>();

            Entities.SoDuKho sodukho;
            sodukho     = new Entities.SoDuKho();
            cl          = new Server_Client.Client();
            this.client = cl.Connect(Luu.IP, Luu.Ports);
            sodukho     = new Entities.SoDuKho("Select");
            clientstrem = cl.SerializeObj(this.client, "SoDuKho", sodukho);
            ddh         = new Entities.SoDuKho[1];
            ddh         = (Entities.SoDuKho[])cl.DeserializeHepper(clientstrem, ddh);

            if (ddh == null)
            {
                ddh = new Entities.SoDuKho[0];
            }

            //
            for (int i = 0; i < ddh.Length; i++)
            {
                if (ddh[i].NgayKetChuyen.Month.ToString().Equals(cbbthang.Text) && ddh[i].NgayKetChuyen.Year.ToString().Equals(cbbnam.Text))
                {
                    listTemp.Add(ddh[i]);
                }
            }
            if (listTemp.ToArray().Length != 0)
            {
                if ((bool)listTemp.ToArray()[0].TrangThai)
                {
                    lbtrangthai.ForeColor = Color.Red;
                    lbtrangthai.Text      = "Kỳ Đã Khóa";
                    tsslthuchien.Enabled  = false;
                }
                else
                {
                    lbtrangthai.ForeColor = Color.Green;
                    lbtrangthai.Text      = "Kỳ Chưa Khóa";
                    tsslthuchien.Enabled  = true;
                }
            }
        }
Exemplo n.º 12
0
        public void LayChiTiet_HangHoaXuat()
        {
            try
            {
                Entities.ChiTietKhoHangTheoHoaHonNhap[] kh1 = new Entities.ChiTietKhoHangTheoHoaHonNhap[1];
                kh1 = new ChiTietKhoHangTheoHoaHonNhap().Select();
                if (kh1 == null)
                {
                    ctHangHoaTheoKho = new Entities.ChiTietKhoHangTheoHoaHonNhap[0];
                    ctBCXH           = new Entities.SoDuKho[0];
                    return;
                }
                ctHangHoaTheoKho = kh1;

                ctBCXH = new Entities.SoDuKho[ctHangHoaTheoKho.Length];
                for (int i = 0; i < ctHangHoaTheoKho.Length; i++)
                {
                    ctBCXH[i]            = new Entities.SoDuKho();
                    ctBCXH[i].MaKho      = ctHangHoaTheoKho[i].Makho;
                    ctBCXH[i].MaHangHoa  = ctHangHoaTheoKho[i].Mahanghoa;
                    ctBCXH[i].SoDuDauKy  = 0;
                    ctBCXH[i].SoDuCuoiKy = 0;
                    ctBCXH[i].PhatSinhNo = 0;
                    ctBCXH[i].PhatSinhCo = 0;
                }
                Entities.SoDuKho[] sdk1 = LaySoDuKhoTheoNgay(DateTime.Now.Month, DateTime.Now.Year);
                for (int i = 0; i < sdk1.Length; i++)
                {
                    for (int j = 0; j < ctBCXH.Length; j++)
                    {
                        if (sdk1[i].MaKho == ctBCXH[j].MaKho && sdk1[i].MaHangHoa == ctBCXH[j].MaHangHoa)
                        {
                            ctBCXH[j].SoDuDauKy = sdk1[i].SoDuDauKy;
                        }
                    }
                }
            }
            catch
            {
            }
        }
Exemplo n.º 13
0
 /// <summary>
 /// Insert Update Bảng
 /// </summary>
 public bool Insert(Entities.SoDuKho pxh)
 {
     try
     {
         bool kt = false;
         sdk = new Constants.SoDuKho();
         Sql = new Constants.Sql();
         string        sql  = Sql.InsertUpdateSoDuKho;
         Connection    conn = new Connection();
         SqlConnection cn   = conn.openConnection();
         SqlCommand    cmd  = new SqlCommand(sql, cn);
         cmd.Parameters.Add(sdk.HanhDong, SqlDbType.VarChar, 20).Value   = pxh.HanhDong;
         cmd.Parameters.Add(sdk.SoDuKhoID, SqlDbType.Int).Value          = pxh.SoDuKhoID;
         cmd.Parameters.Add(sdk.MaSoDuKho, SqlDbType.VarChar, 20).Value  = pxh.MaSoDuKho;
         cmd.Parameters.Add(sdk.MaKho, SqlDbType.VarChar, 20).Value      = pxh.MaKho;
         cmd.Parameters.Add(sdk.MaHangHoa, SqlDbType.VarChar, 50).Value  = pxh.MaHangHoa;
         cmd.Parameters.Add(sdk.SoDuDauKy, SqlDbType.Int).Value          = pxh.SoDuDauKy;
         cmd.Parameters.Add(sdk.NgayKetChuyen, SqlDbType.DateTime).Value = pxh.NgayKetChuyen;
         cmd.Parameters.Add(sdk.SoDuCuoiKy, SqlDbType.Int).Value         = pxh.SoDuCuoiKy;
         cmd.Parameters.Add(sdk.TrangThai, SqlDbType.Bit).Value          = pxh.TrangThai;
         int i = cmd.ExecuteNonQuery();
         if (i == 1)
         {
             kt = true;
         }
         else
         {
             kt = false;
         }
         cmd.Connection.Dispose();
         cn.Close();
         conn.closeConnection();
         cn   = null;
         conn = null;
         return(kt);
     }
     catch
     {
         return(false);
     }
 }
Exemplo n.º 14
0
 private void tsslChon_Click(object sender, EventArgs e)
 {
     if (DoiTuong == "theo_HDNhap")
     {
         frmXuLy_DieuChuyenKhoNoiBo.maHDNhap = dgvHienThi.CurrentRow.Cells[2].Value.ToString();
         this.Close();
     }
     else
     if (DoiTuong == "theo_Kho")
     {
         frmXuLy_DieuChuyenKhoNoiBo.ct = dgvHienThi.CurrentRow;
         this.Close();
     }
     else
     if (DoiTuong == "HangHoa")
     {
         Entities.SoDuKho sdk = new Entities.SoDuKho();
         sdk.MaHangHoa = dgvHienThi.CurrentRow.Cells["MaHangHoa"].Value.ToString();
         //  sdk.TenHangHoa = dgvHienThi.Rows[e.RowIndex].Cells["TenHangHoa"].Value.ToString();
         frmSoDuKhoHang.sdkho = sdk;
         this.Close();
     }
 }
Exemplo n.º 15
0
        public void LayChiTiet_HangHoaXuat()
        {
            try
            {
                cl = new Server_Client.Client();
                this.client = cl.Connect(Luu.IP, Luu.Ports);
                Entities.ChiTietKhoHangTheoHoaHonNhap nv = new Entities.ChiTietKhoHangTheoHoaHonNhap("Select");
                clientstrem = cl.SerializeObj(this.client, "ChiTietKho", nv);
                Entities.ChiTietKhoHangTheoHoaHonNhap[] kh1 = new Entities.ChiTietKhoHangTheoHoaHonNhap[1];
                kh1 = (Entities.ChiTietKhoHangTheoHoaHonNhap[])cl.DeserializeHepper1(clientstrem, kh1);

                if (kh1 == null)
                {
                    ctHangHoaTheoKho = new Entities.ChiTietKhoHangTheoHoaHonNhap[0];
                    ctBCXH = new Entities.SoDuKho[0];
                    return;
                }
                ctHangHoaTheoKho = kh1;

                ctBCXH = new Entities.SoDuKho[ctHangHoaTheoKho.Length];
                for (int i = 0; i < ctHangHoaTheoKho.Length; i++)
                {
                    ctBCXH[i] = new Entities.SoDuKho();
                    ctBCXH[i].MaKho = ctHangHoaTheoKho[i].Makho;
                    ctBCXH[i].MaHangHoa = ctHangHoaTheoKho[i].Mahanghoa;
                    ctBCXH[i].SoDuDauKy = 0;
                    ctBCXH[i].SoDuCuoiKy = 0;
                    ctBCXH[i].PhatSinhNo = 0;
                    ctBCXH[i].PhatSinhCo = 0;
                }
                Entities.SoDuKho[] sdk1 = LaySoDuKhoTheoNgay(Convert.ToInt32(cbbthang.Text), Convert.ToInt32(cbbnam.Text));
                for (int i = 0; i < sdk1.Length; i++)
                {
                    for (int j = 0; j < ctBCXH.Length; j++)
                    {
                        if (sdk1[i].MaKho == ctBCXH[j].MaKho && sdk1[i].MaHangHoa == ctBCXH[j].MaHangHoa)
                        {
                            ctBCXH[j].SoDuDauKy = sdk1[i].SoDuDauKy;
                        }
                    }

                }
            }
            catch
            {
            }
        }
Exemplo n.º 16
0
 /// <summary>
 /// Select Bảng
 /// </summary>
 /// <returns></returns>
 public Entities.SoDuKho[] Select()
 {
     try
     {
         List<Entities.SoDuKho> L = new List<Entities.SoDuKho>();
         SqlCommand cmd = new SqlCommand("exec sp_SelectSoDuKhosAll", new Connection().openConnection());
         SqlDataReader dr = cmd.ExecuteReader(CommandBehavior.CloseConnection);
         while (dr.Read())
         {
             Entities.SoDuKho sdk = new Entities.SoDuKho();
             sdk.MaSoDuKho = dr["MaSoDuKho"].ToString();
             sdk.MaKho = dr["MaKho"].ToString();
             sdk.MaHangHoa = dr["MaHangHoa"].ToString();
             sdk.TenHangHoa = dr["TenHangHoa"].ToString();
             sdk.SoDuDauKy = Convert.ToInt32(dr["SoDuDauKy"].ToString());
             sdk.NgayKetChuyen = Convert.ToDateTime(dr["NgayKetChuyen"].ToString());
             sdk.SoDuCuoiKy = Convert.ToInt32(dr["SoDuCuoiKy"].ToString());
             sdk.TrangThai = Boolean.Parse(dr["TrangThai"].ToString());
             L.Add(sdk);
         }
         cmd.Connection.Dispose();
         //Giai phong bo nho
         return L.ToArray();
     }
     catch { return null; }
 }
Exemplo n.º 17
0
 public void SoDuKho()
 {
     try
     {
         cl = new Server_Client.Client();
         this.client1 = cl.Connect(Luu.IP, Luu.Ports);
         Entities.SoDuKho ctxh = new Entities.SoDuKho("Select");
         clientstrem = cl.SerializeObj(this.client1, "SoDuKho", ctxh);
         sodukho = (Entities.SoDuKho[])cl.DeserializeHepper1(clientstrem, sodukho);
         if (sodukho == null)
         {
             sodukho = new Entities.SoDuKho[0];
             return;
         }
     }
     catch
     {
     }
 }
Exemplo n.º 18
0
        public void LayChiTiet_HangHoaXuat()
        {
            try
            {

                Entities.ChiTietKhoHangTheoHoaHonNhap[] kh1 = new Entities.ChiTietKhoHangTheoHoaHonNhap[1];
                kh1 = new ChiTietKhoHangTheoHoaHonNhap().Select();
                if (kh1 == null)
                {
                    ctHangHoaTheoKho = new Entities.ChiTietKhoHangTheoHoaHonNhap[0];
                    ctBCXH = new Entities.SoDuKho[0];
                    return;
                }
                ctHangHoaTheoKho = kh1;

                ctBCXH = new Entities.SoDuKho[ctHangHoaTheoKho.Length];
                for (int i = 0; i < ctHangHoaTheoKho.Length; i++)
                {
                    ctBCXH[i] = new Entities.SoDuKho();
                    ctBCXH[i].MaKho = ctHangHoaTheoKho[i].Makho;
                    ctBCXH[i].MaHangHoa = ctHangHoaTheoKho[i].Mahanghoa;
                    ctBCXH[i].SoDuDauKy = 0;
                    ctBCXH[i].SoDuCuoiKy = 0;
                    ctBCXH[i].PhatSinhNo = 0;
                    ctBCXH[i].PhatSinhCo = 0;
                }
                Entities.SoDuKho[] sdk1 = LaySoDuKhoTheoNgay(DateTime.Now.Month, DateTime.Now.Year);
                for (int i = 0; i < sdk1.Length; i++)
                {
                    for (int j = 0; j < ctBCXH.Length; j++)
                    {
                        if (sdk1[i].MaKho == ctBCXH[j].MaKho && sdk1[i].MaHangHoa == ctBCXH[j].MaHangHoa)
                        {
                            ctBCXH[j].SoDuDauKy = sdk1[i].SoDuDauKy;
                        }
                    }

                }
            }
            catch
            {
            }
        }
Exemplo n.º 19
0
 public Entities.SoDuKho[] LaySoDuKhoTheoNgay(int thangKC, int namKC)
 {
     int count = 0;
     for (int i = 0; i < sdk.Length; i++)
     {
         if (sdk[i].NgayKetChuyen.Month == thangKC && sdk[i].NgayKetChuyen.Year == namKC)
         {
             count++;
         }
     }
     Entities.SoDuKho[] sdk1 = new Entities.SoDuKho[count];
     count = 0;
     for (int i = 0; i < sdk.Length; i++)
     {
         if (sdk[i].NgayKetChuyen.Month == thangKC && sdk[i].NgayKetChuyen.Year == namKC)
         {
             sdk1[count] = sdk[i];
             count++;
         }
     }
     if (sdk1.Length == 0)
     {
         return new Entities.SoDuKho[0];
     }
     else
         return sdk1;
 }
Exemplo n.º 20
0
 public void LaySoDuKho()
 {
     Entities.SoDuKho[] ddh = new Entities.SoDuKho[1];
     ddh = new BizLogic.SoDuKho().Select();
     if (ddh != null)
     {
         sdk = ddh;
     }
     else
     {
         sdk = new Entities.SoDuKho[0];
     }
 }
Exemplo n.º 21
0
 private void tsslChon_Click(object sender, EventArgs e)
 {
     if (DoiTuong == "theo_HDNhap")
     {
         frmXuLy_DieuChuyenKhoNoiBo.maHDNhap = dgvHienThi.CurrentRow.Cells[2].Value.ToString();
         this.Close();
     }
     else
         if (DoiTuong == "theo_Kho")
         {
             frmXuLy_DieuChuyenKhoNoiBo.ct = dgvHienThi.CurrentRow;
             this.Close();
         }
         else
             if (DoiTuong == "HangHoa")
             {
                 Entities.SoDuKho sdk = new Entities.SoDuKho();
                 sdk.MaHangHoa = dgvHienThi.CurrentRow.Cells["MaHangHoa"].Value.ToString();
                 //  sdk.TenHangHoa = dgvHienThi.Rows[e.RowIndex].Cells["TenHangHoa"].Value.ToString();
                 frmSoDuKhoHang.sdkho = sdk;
                 this.Close();
             }
 }
Exemplo n.º 22
0
 private void dgvHienThi_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
 {
     if (e.RowIndex >= 0)
     {
         if (DoiTuong == "theo_HDNhap")
         {
             frmXuLy_DieuChuyenKhoNoiBo.maHDNhap = dgvHienThi.Rows[e.RowIndex].Cells[2].Value.ToString();
             this.Close();
         }
         else
             if (DoiTuong == "theo_Kho")
             {
                 frmXuLy_DieuChuyenKhoNoiBo.ct = dgvHienThi.Rows[e.RowIndex];
                 this.Close();
             }
             else
                 if (DoiTuong == "HangHoa")
                 {
                     Entities.SoDuKho sdk = new Entities.SoDuKho();
                     sdk.MaHangHoa = dgvHienThi.Rows[e.RowIndex].Cells["MaHangHoa"].Value.ToString();
                     frmSoDuKhoHang.sdkho = sdk;
                     this.Close();
                 }
     }
 }
Exemplo n.º 23
0
 public void LaySoDuKho()
 {
     Entities.SoDuKho sodukho;
     sodukho = new Entities.SoDuKho();
     cl = new Server_Client.Client();
     this.client = cl.Connect(Luu.IP, Luu.Ports);
     sodukho = new Entities.SoDuKho("Select");
     clientstrem = cl.SerializeObj(this.client, "SoDuKho", sodukho);
     ddh = new Entities.SoDuKho[1];
     ddh = (Entities.SoDuKho[])cl.DeserializeHepper(clientstrem, ddh);
     if (ddh != null)
     {
         sdk = ddh;
     }
     else
     {
         sdk = new Entities.SoDuKho[0];
     }
 }
Exemplo n.º 24
0
 private void toolStripButton1_Click(object sender, EventArgs e)
 {
     bool kt1 = true;
         for (int i = 0; i < dgvsodukhohang.RowCount; i++)
         {
             if (dgvsodukhohang.Rows[i].Cells["MaHangHoa"].Value.ToString() == tsslma.Text)
             {
                 kt1 = false;
                 break;
             }
         }
         if (kt1)
         {
             string ma = LayID("SoDuKho");
             Entities.KhoHang kh = (Entities.KhoHang)cbbkhohang.SelectedItem;
             string makho = kh.MaKho;
             cl = new Server_Client.Client();
             this.client = cl.Connect(Luu.IP, Luu.Ports);
             Entities.SoDuKho sodukho = new Entities.SoDuKho("Insert", 1, ma,makho, tsslma.Text, Convert.ToInt32(tsslsodudauky.Text), 0, datesv, 0, 0, false);
             clientstrem = cl.SerializeObj(this.client, "SoDuKho", sodukho);
             bool msg = true;
             msg = (bool)cl.DeserializeHepper(clientstrem, msg);
             if (msg)
             {
                 cl = new Server_Client.Client();
                 this.client = cl.Connect(Luu.IP, Luu.Ports);
                 Entities.ChiTietKhoHangTheoHoaHonNhap[] ctkho = new Entities.ChiTietKhoHangTheoHoaHonNhap[1];
                 ctkho[0] = new Entities.ChiTietKhoHangTheoHoaHonNhap();
                 ctkho[0].Hanhdong = "UpdateCong";
                 ctkho[0].Makho = makho;
                 ctkho[0].Mahanghoa = tsslma.Text;
                 ctkho[0].Soluong = Convert.ToInt32(tsslsodudauky.Text);
                 clientstrem = cl.SerializeObj(this.client, "ThemChiTietKhoHang", ctkho);
                 int i = 0;
                 i = (int)cl.DeserializeHepper(clientstrem, i);
                 HienThi();
                 tsslma.Text = "<F4>-tra cứu";
                 tsslsodudauky.Text = "0";
                 tsslten.Text = "";
             }
             else
             {
                 MessageBox.Show("Insert thất Bại");
             }
         }
         else
             MessageBox.Show("Hàng Hóa đã được nhập số dư đầu kỳ - Không thể thêm mới");
 }
Exemplo n.º 25
0
        public void HienThi()
        {
            List<Entities.SoDuKho> listTemp = new List<Entities.SoDuKho>();
            Entities.SoDuKho sodukho;
            sodukho = new Entities.SoDuKho();
            cl = new Server_Client.Client();
            this.client = cl.Connect(Luu.IP, Luu.Ports);
            sodukho = new Entities.SoDuKho("Select");
            clientstrem = cl.SerializeObj(this.client, "SoDuKho", sodukho);
            ddh = new Entities.SoDuKho[1];
            ddh = (Entities.SoDuKho[])cl.DeserializeHepper(clientstrem, ddh);

            if (ddh == null)
                ddh = new Entities.SoDuKho[0];

            //
            for (int i = 0; i < ddh.Length; i++)
            {
                if (ddh[i].NgayKetChuyen.Month.ToString().Equals(cbbthang.Text) && ddh[i].NgayKetChuyen.Year.ToString().Equals(cbbnam.Text))
                {
                    listTemp.Add(ddh[i]);
                }
            }
            if (listTemp.ToArray().Length != 0)
            {

                if ((bool)listTemp.ToArray()[0].TrangThai)
                {
                    lbtrangthai.ForeColor = Color.Red;
                    lbtrangthai.Text = "Kỳ Đã Khóa";
                    tsslthuchien.Enabled = false;

                }
                else
                {
                    lbtrangthai.ForeColor = Color.Green;
                    lbtrangthai.Text = "Kỳ Chưa Khóa";
                    tsslthuchien.Enabled = true;
                }
            }
        }
Exemplo n.º 26
0
        private void dgvsodukhohang_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
        {
            if (e.RowIndex>-1)
            {
                if (dgvsodukhohang.RowCount>0)
                {
                    if (!(bool)dgvsodukhohang.Rows[0].Cells["TrangThai"].Value)
                    {
                        bool kt = true;
                        for (int i = 0; i < ddh.Length; i++)
                        {
                            if (ddh[i].NgayKetChuyen.Month == Convert.ToInt32(cbbthang.Text) - 1 && ddh[i].NgayKetChuyen.Year.ToString() == cbbnam.Text)
                            {
                                kt = false;
                                break;
                            }
                        }
                        if (kt)
                        {
                            string maSoDuKho=dgvsodukhohang.Rows[e.RowIndex].Cells["MaSoDuKho"].Value.ToString();
                            string maHangHoa = dgvsodukhohang.Rows[e.RowIndex].Cells["MaHangHoa"].Value.ToString();
                            string makho = dgvsodukhohang.Rows[e.RowIndex].Cells["MaKho"].Value.ToString();

                            int sddk = Convert.ToInt32(dgvsodukhohang.Rows[e.RowIndex].Cells["SoDuDauKy"].Value.ToString());
                            cl = new Server_Client.Client();
                            this.client = cl.Connect(Luu.IP, Luu.Ports);
                            Entities.SoDuKho sodukho = new Entities.SoDuKho("Delete", 1, maSoDuKho,makho, maHangHoa, sddk, 0, datesv, 0, 0, false);
                            clientstrem = cl.SerializeObj(this.client, "SoDuKho", sodukho);
                            bool msg = true;
                            msg = (bool)cl.DeserializeHepper(clientstrem, msg);
                            if (msg)
                            {
                                cl = new Server_Client.Client();
                                this.client = cl.Connect(Luu.IP, Luu.Ports);
                                Entities.ChiTietKhoHangTheoHoaHonNhap[] ctkho = new Entities.ChiTietKhoHangTheoHoaHonNhap[1];
                                ctkho[0] = new Entities.ChiTietKhoHangTheoHoaHonNhap();
                                ctkho[0].Hanhdong = "Update";
                                ctkho[0].Makho = makho;
                                ctkho[0].Mahanghoa = maHangHoa;
                                ctkho[0].Soluong = sddk;
                                clientstrem = cl.SerializeObj(this.client, "ThemChiTietKhoHang", ctkho);

                                tsslma.Text = maHangHoa;
                                tsslsodudauky.Text = sddk.ToString();
                                tsslten.Text = LayTenHangHoa(maHangHoa);
                                HienThi();
                            }
                            else
                            {
                                MessageBox.Show("Insert thất Bại");
                            }
                        }
                    }
                }
            }
        }