コード例 #1
0
        public void Update(int IdThuoc,short IdKho,string KieuThuocVt,int? SoluongDutru)
        {
            TDutruThuoc item = new TDutruThuoc();
            item.MarkOld();
            item.IsLoaded = true;

            item.IdThuoc = IdThuoc;

            item.IdKho = IdKho;

            item.KieuThuocVt = KieuThuocVt;

            item.SoluongDutru = SoluongDutru;

            item.Save(UserName);
        }
コード例 #2
0
        public void Insert(int IdThuoc,short IdKho,string KieuThuocVt,int? SoluongDutru)
        {
            TDutruThuoc item = new TDutruThuoc();

            item.IdThuoc = IdThuoc;

            item.IdKho = IdKho;

            item.KieuThuocVt = KieuThuocVt;

            item.SoluongDutru = SoluongDutru;

            item.Save(UserName);
        }
コード例 #3
0
        private void grdList_CellUpdated(object sender, Janus.Windows.GridEX.ColumnActionEventArgs e)
        {
            try
            {
                if (grdList.CurrentRow != null && grdList.CurrentRow.RowType == RowType.Record)
                {
                    int   IDTHUOC   = Utility.Int32Dbnull(grdList.GetValue(DmucThuoc.Columns.IdThuoc), 0);
                    Int16 idkhoxuat = Utility.Int16Dbnull(cboKhoxuat.SelectedValue);

                    Int16 Idkhonhan       = Utility.Int16Dbnull(cboKhonhan.SelectedValue);
                    int   SOLUONG         = Utility.Int32Dbnull(grdList.GetValue("SO_LUONG"), 0);
                    int   IdThuocKho      = Utility.Int32Dbnull(grdList.GetValue("id_thuockho"));
                    int   SLUONG_TRONGKHO = Utility.Int32Dbnull(grdList.GetValue("SLUONG_TRONGKHO"), 0);
                    grdList.CurrentRow.BeginEdit();
                    if (SOLUONG <= 0)
                    {
                        grdList.CurrentRow.Cells["COQUANHE"].Value         = 0;
                        grdList.CurrentRow.Cells["SO_LUONG"].Value         = 0;
                        grdList.CurrentRow.Cells["SLUONG_CANCHUYEN"].Value = 0;
                    }
                    else
                    {
                        grdList.CurrentRow.Cells["COQUANHE"].Value         = 1;
                        grdList.CurrentRow.Cells["SO_LUONG"].Value         = SOLUONG;
                        grdList.CurrentRow.Cells["SLUONG_CANCHUYEN"].Value = SOLUONG - SLUONG_TRONGKHO;
                    }
                    grdList.CurrentRow.EndEdit();
                    TDutruThuocCollection lst =
                        new Select().From(TDutruThuoc.Schema).Where(TDutruThuoc.Columns.IdThuoc).IsEqualTo(IDTHUOC)
                        .And(TDutruThuoc.Columns.IdKho).IsEqualTo(idkhoxuat)
                        .And(TDutruThuoc.Columns.IdKhonhan).IsEqualTo(Idkhonhan)
                        .And(TDutruThuoc.Columns.IdThuockho).IsEqualTo(IdThuocKho)
                        .And(TDutruThuoc.Columns.KieuThuocVt).IsEqualTo(KIEU_THUOC_VT)
                        .ExecuteAsCollection <TDutruThuocCollection>();
                    if (lst.Count > 0)
                    {
                        if (SOLUONG <= 0)
                        {
                            new Delete().From(TDutruThuoc.Schema).Where(TDutruThuoc.Columns.IdThuoc).IsEqualTo(IDTHUOC)
                            .And(TDutruThuoc.Columns.IdKho).IsEqualTo(idkhoxuat)
                            .And(TDutruThuoc.Columns.KieuThuocVt).IsEqualTo(KIEU_THUOC_VT).Execute();
                        }
                        else
                        {
                            new Update(TDutruThuoc.Schema)
                            .Set(TDutruThuoc.Columns.SoluongDutru).EqualTo(SOLUONG)
                            .Where(TDutruThuoc.Columns.IdThuoc).IsEqualTo(IDTHUOC).And(TDutruThuoc.Columns.IdKho).
                            IsEqualTo(idkhoxuat)
                            .And(TDutruThuoc.Columns.KieuThuocVt).IsEqualTo(KIEU_THUOC_VT).Execute();
                        }
                    }
                    else
                    {
                        TDutruThuoc objThongTin = new TDutruThuoc();
                        objThongTin.IdThuoc      = IDTHUOC;
                        objThongTin.KieuThuocVt  = KIEU_THUOC_VT;
                        objThongTin.IdKho        = idkhoxuat;
                        objThongTin.SoluongDutru = SOLUONG;
                        objThongTin.IdKhonhan    = Idkhonhan;
                        objThongTin.IdThuockho   = IdThuocKho;
                        objThongTin.IsNew        = true;
                        objThongTin.Save();
                    }
                    grdList.UpdateData();
                    grdList.Refetch();
                    m_Thuoc.AcceptChanges();
                    Modifyconmand();
                }
            }
            catch (Exception ex)
            {
                Utility.ShowMsg("Lỗi:", ex.Message);
            }
        }
コード例 #4
0
        void txtSoluongdutru_KeyDown(object sender, KeyEventArgs e)
        {
            try
            {
                if (e.KeyCode == Keys.Enter && Utility.Int32Dbnull(txtthuoc.MyID, -1) > 0)
                {
                    int   IDTHUOC = Utility.Int32Dbnull(txtthuoc.MyID, -1);
                    Int16 IDKHO   = Utility.Int16Dbnull(cboKhoxuat.SelectedValue);
                    int   SOLUONG = Utility.Int32Dbnull(Utility.DecimaltoDbnull(txtSoluongdutru.Text, 0));
                    var   q       = from p in grdList.GetDataRows()
                                    where Utility.Int32Dbnull(p.Cells[DmucThuoc.Columns.IdThuoc].Value, 0) == IDTHUOC
                                    select p;

                    int SLUONG_TRONGKHO = q.Count() > 0 ? Utility.Int32Dbnull(q.FirstOrDefault().Cells["SLUONG_TRONGKHO"].Value, 0) : 0;

                    int SLUONG_CANCHUYEN = SOLUONG - SLUONG_TRONGKHO;
                    SLUONG_CANCHUYEN = SLUONG_CANCHUYEN <= 0 ? 0 : SLUONG_CANCHUYEN;

                    DataRow[] dr = m_Thuoc.Select(DmucThuoc.Columns.IdThuoc + "=" + IDTHUOC.ToString());
                    if (dr.Length > 0)
                    {
                        dr[0]["SO_LUONG"] = SOLUONG <= 0 ? 0 : SOLUONG;
                        dr[0]["COQUANHE"] = SOLUONG <= 0 ? 0 : 1;
                        grdList.SetValue("SLUONG_CANCHUYEN", SLUONG_CANCHUYEN);
                        m_Thuoc.AcceptChanges();
                    }

                    TDutruThuocCollection lst =
                        new Select().From(TDutruThuoc.Schema).Where(TDutruThuoc.Columns.IdThuoc).IsEqualTo(IDTHUOC)
                        .And(TDutruThuoc.Columns.IdKho).IsEqualTo(IDKHO)
                        .And(TDutruThuoc.Columns.KieuThuocVt).IsEqualTo(KIEU_THUOC_VT)
                        .ExecuteAsCollection <TDutruThuocCollection>();
                    if (lst.Count > 0)
                    {
                        if (SOLUONG <= 0)
                        {
                            new Delete().From(TDutruThuoc.Schema).Where(TDutruThuoc.Columns.IdThuoc).IsEqualTo(IDTHUOC)
                            .And(TDutruThuoc.Columns.IdKho).IsEqualTo(IDKHO)
                            .And(TDutruThuoc.Columns.KieuThuocVt).IsEqualTo(KIEU_THUOC_VT).Execute();
                        }
                        else
                        {
                            new Update(TDutruThuoc.Schema)
                            .Set("SO_LUONG").EqualTo(SOLUONG)
                            .Where(TDutruThuoc.Columns.IdThuoc).IsEqualTo(IDTHUOC).And(TDutruThuoc.Columns.IdKho).
                            IsEqualTo(IDKHO)
                            .And(TDutruThuoc.Columns.KieuThuocVt).IsEqualTo(KIEU_THUOC_VT).Execute();
                        }
                    }
                    else
                    {
                        TDutruThuoc objThongTin = new TDutruThuoc();
                        objThongTin.IdThuoc      = IDTHUOC;
                        objThongTin.KieuThuocVt  = KIEU_THUOC_VT;
                        objThongTin.IdKho        = IDKHO;
                        objThongTin.SoluongDutru = SOLUONG;
                        objThongTin.IsNew        = true;
                        objThongTin.Save();
                    }
                    txtthuoc.ResetText();
                    txtthuoc.Focus();
                }
            }
            catch
            {
            }
            finally
            {
            }
        }
コード例 #5
0
        void txtSoluongdutru_KeyDown(object sender, KeyEventArgs e)
        {
            try
            {
                if (e.KeyCode == Keys.Enter && Utility.Int32Dbnull(txtthuoc.MyID, -1) > 0)
                {
                    int IDTHUOC = Utility.Int32Dbnull(txtthuoc.MyID, -1);
                    Int16 IDKHO = Utility.Int16Dbnull(cboKho.SelectedValue);
                    int SOLUONG = Utility.Int32Dbnull(Utility.DecimaltoDbnull(txtSoluongdutru.Text, 0));
                    var q = from p in grdList.GetDataRows()
                            where Utility.Int32Dbnull(p.Cells[DmucThuoc.Columns.IdThuoc].Value, 0) == IDTHUOC
                            select p;

                    int SLUONG_TRONGKHO = q.Count() > 0 ? Utility.Int32Dbnull(q.FirstOrDefault().Cells["SLUONG_TRONGKHO"].Value, 0) : 0;

                    int SLUONG_CANCHUYEN = SOLUONG - SLUONG_TRONGKHO;
                    SLUONG_CANCHUYEN = SLUONG_CANCHUYEN <= 0 ? 0 : SLUONG_CANCHUYEN;

                    DataRow[] dr = m_Thuoc.Select(DmucThuoc.Columns.IdThuoc + "=" + IDTHUOC.ToString());
                    if (dr.Length > 0)
                    {
                        dr[0]["SO_LUONG"] = SOLUONG <= 0 ? 0 : SOLUONG;
                        dr[0]["COQUANHE"] = SOLUONG <= 0 ? 0 : 1;
                        grdList.SetValue("SLUONG_CANCHUYEN", SLUONG_CANCHUYEN);
                        m_Thuoc.AcceptChanges();
                    }

                    TDutruThuocCollection lst =
                        new Select().From(TDutruThuoc.Schema).Where(TDutruThuoc.Columns.IdThuoc).IsEqualTo(IDTHUOC)
                            .And(TDutruThuoc.Columns.IdKho).IsEqualTo(IDKHO)
                            .And(TDutruThuoc.Columns.KieuThuocVt).IsEqualTo(KIEU_THUOC_VT)
                            .ExecuteAsCollection<TDutruThuocCollection>();
                    if (lst.Count > 0)
                    {
                        if (SOLUONG <= 0)
                        {
                            new Delete().From(TDutruThuoc.Schema).Where(TDutruThuoc.Columns.IdThuoc).IsEqualTo(IDTHUOC)
                            .And(TDutruThuoc.Columns.IdKho).IsEqualTo(IDKHO)
                            .And(TDutruThuoc.Columns.KieuThuocVt).IsEqualTo(KIEU_THUOC_VT).Execute();
                        }
                        else
                        {
                            new Update(TDutruThuoc.Schema)
                                .Set("SO_LUONG").EqualTo(SOLUONG)
                                .Where(TDutruThuoc.Columns.IdThuoc).IsEqualTo(IDTHUOC).And(TDutruThuoc.Columns.IdKho).
                                IsEqualTo(IDKHO)
                                .And(TDutruThuoc.Columns.KieuThuocVt).IsEqualTo(KIEU_THUOC_VT).Execute();
                        }

                    }
                    else
                    {
                        TDutruThuoc objThongTin = new TDutruThuoc();
                        objThongTin.IdThuoc = IDTHUOC;
                        objThongTin.KieuThuocVt = KIEU_THUOC_VT;
                        objThongTin.IdKho = IDKHO;
                        objThongTin.SoluongDutru = SOLUONG;
                        objThongTin.IsNew = true;
                        objThongTin.Save();
                    }
                    txtthuoc.ResetText();
                    txtthuoc.Focus();
                }
            }
            catch
            {
            }
            finally
            {

            }
        }
コード例 #6
0
        private void grdList_CellUpdated(object sender, Janus.Windows.GridEX.ColumnActionEventArgs e)
        {
            try
            {
                if (grdList.CurrentRow != null && grdList.CurrentRow.RowType == RowType.Record)
                {
                    int IDTHUOC = Utility.Int32Dbnull(grdList.GetValue(DmucThuoc.Columns.IdThuoc), 0);
                    Int16 IDKHO = Utility.Int16Dbnull(cboKho.SelectedValue);
                    int SOLUONG = Utility.Int32Dbnull(grdList.GetValue("SO_LUONG"), 0);
                    int SLUONG_TRONGKHO = Utility.Int32Dbnull(grdList.GetValue("SLUONG_TRONGKHO"), 0);
                    grdList.CurrentRow.BeginEdit();
                    if (SOLUONG <= 0)
                    {
                        grdList.CurrentRow.Cells["COQUANHE"].Value= 0;
                        grdList.CurrentRow.Cells["SO_LUONG"].Value= 0;
                        grdList.CurrentRow.Cells["SLUONG_CANCHUYEN"].Value = 0;
                    }
                    else
                    {
                        grdList.CurrentRow.Cells["COQUANHE"].Value= 1;
                        grdList.CurrentRow.Cells["SO_LUONG"].Value= SOLUONG;
                        grdList.CurrentRow.Cells["SLUONG_CANCHUYEN"].Value= SOLUONG - SLUONG_TRONGKHO;
                    }
                    grdList.CurrentRow.EndEdit();
                    TDutruThuocCollection lst =
                        new Select().From(TDutruThuoc.Schema).Where(TDutruThuoc.Columns.IdThuoc).IsEqualTo(IDTHUOC)
                            .And(TDutruThuoc.Columns.IdKho).IsEqualTo(IDKHO)
                            .And(TDutruThuoc.Columns.KieuThuocVt).IsEqualTo(KIEU_THUOC_VT)
                            .ExecuteAsCollection<TDutruThuocCollection>();
                    if (lst.Count > 0)
                    {
                        if (SOLUONG <= 0)
                            new Delete().From(TDutruThuoc.Schema).Where(TDutruThuoc.Columns.IdThuoc).IsEqualTo(IDTHUOC)
                            .And(TDutruThuoc.Columns.IdKho).IsEqualTo(IDKHO)
                            .And(TDutruThuoc.Columns.KieuThuocVt).IsEqualTo(KIEU_THUOC_VT).Execute();
                        else
                            new Update(TDutruThuoc.Schema)
                                .Set(TDutruThuoc.Columns.SoluongDutru).EqualTo(SOLUONG)
                                .Where(TDutruThuoc.Columns.IdThuoc).IsEqualTo(IDTHUOC).And(TDutruThuoc.Columns.IdKho).
                                IsEqualTo(IDKHO)
                                .And(TDutruThuoc.Columns.KieuThuocVt).IsEqualTo(KIEU_THUOC_VT).Execute();

                    }
                    else
                    {
                        TDutruThuoc objThongTin = new TDutruThuoc();
                        objThongTin.IdThuoc = IDTHUOC;
                        objThongTin.KieuThuocVt = KIEU_THUOC_VT;
                        objThongTin.IdKho = IDKHO;
                        objThongTin.SoluongDutru = SOLUONG;
                        objThongTin.IsNew = true;
                        objThongTin.Save();

                    }
                    grdList.UpdateData();
                    grdList.Refetch();
                    m_Thuoc.AcceptChanges();
                }
            }
            catch (Exception exception)
            {

            }
        }