Example #1
0
        private void simpleButton2_Click(object sender, EventArgs e)
        {
            /*
             * MatComboBox.EditValue = IHelper.ShowDirectList(MatComboBox.EditValue, 5);
             * _wbd.MatId = MatComboBox.EditValue != null && MatComboBox.EditValue != DBNull.Value ? (int)MatComboBox.EditValue : _wbd.MatId;*/

            using (var f = new frmWhCatalog(1))
            {
                f.uc.whKagentList.Enabled = false;
                f.uc.OnDateEdit.Enabled   = false;
                f.uc.bar3.Visible         = false;
                f.uc.ByWhBtn.Down         = true;
                f.uc.splitContainerControl1.SplitterPosition = 0;
                using (var db = new BaseEntities())
                {
                    f.uc.WHTreeList.DataSource = db.GetWhTree(DBHelper.CurrentUser.UserId, 2).Where(w => w.GType == 1 && w.Num == _wbd.WId).ToList();
                }
                f.uc.GrpNameGridColumn.GroupIndex = 0;

                f.uc.isDirectList = true;
                if (f.ShowDialog() == DialogResult.OK)
                {
                    _wbd.MatId            = f.uc.focused_wh_mat.MatId;
                    MatComboBox.EditValue = _wbd.MatId;
                    SetValue();
                }
            }
        }
Example #2
0
        private void MatEditBtn_Click(object sender, EventArgs e)
        {
            using (var f = new frmWhCatalog(1))
            {
                f.uc.whKagentList.EditValue = _ka_id;
                f.uc.whKagentList.Enabled   = false;
                f.uc.OnDateEdit.Enabled     = false;
                f.uc.bar3.Visible           = false;
                f.uc.ByWhBtn.Down           = true;
                f.uc.splitContainerControl1.SplitterPosition = 0;
                f.uc.WHTreeList.DataSource        = new BaseEntities().GetWhTree(DBHelper.CurrentUser.UserId, 2).Where(w => w.GType == 1 && w.Num == _wbd.WId).ToList();
                f.uc.GrpNameGridColumn.GroupIndex = 0;

                f.uc.isDirectList = true;
                if (f.ShowDialog() == DialogResult.OK)
                {
                    _wbd.MatId            = f.uc.focused_wh_mat.MatId;
                    MatComboBox.EditValue = _wbd.MatId;

                    GetContent();
                    GetPos();
                    SetAmount();
                }
            }
        }
Example #3
0
        static public void ShowMatListByWH3(BaseEntities db, WaybillList wb, String WID)
        {
            using (var f = new frmWhCatalog(1))
            {
                f.uc.xtraTabPage4.PageVisible             = false;
                f.uc.xtraTabPage5.PageVisible             = false;
                f.uc.xtraTabPage9.PageVisible             = false;
                f.uc.MatListTabPage.PageVisible           = true;
                f.uc.xtraTabControl1.SelectedTabPageIndex = 4;
                f.uc.gridColumn49.Visible        = false;
                f.uc.gridColumn51.Visible        = false;
                f.uc.gridColumn52.Visible        = false;
                f.uc.MatListGridColumnWh.Visible = (WID == "*");
                f.uc.bar3.Visible = false;
                f.uc.ByWhBtn.Down = true;
                f.uc.splitContainerControl1.SplitterPosition = 0;


                using (var _db = new BaseEntities())
                {
                    int wid;
                    if (int.TryParse(WID, out wid))
                    {
                        f.uc.WHTreeList.DataSource = _db.GetWhTree(DBHelper.CurrentUser.UserId, 2).Where(w => w.GType == 1 && w.Num == wid).ToList();
                    }
                    else
                    {
                        f.uc.WHTreeList.DataSource = _db.GetWhTree(DBHelper.CurrentUser.UserId, 2).Where(w => w.GType == 1).ToList();
                    }
                    f.uc.GrpNameGridColumn.GroupIndex = 0;
                }

                f.uc.wb        = wb;
                f.uc.isMatList = true;
                if (f.ShowDialog() == DialogResult.OK)
                {
                    foreach (var item in f.uc.custom_mat_list)
                    {
                        var wbd = db.WaybillDet.Add(new WaybillDet
                        {
                            WbillId      = wb.WbillId,
                            OnDate       = wb.OnDate,
                            MatId        = item.MatId,
                            WId          = (WID != "*") ? Convert.ToInt32(WID) : item.WId,
                            Amount       = item.Amount,
                            Price        = item.AvgPrice,// item.Price ,
                            Discount     = wb.WType == -20 ? item.Amount : 0,
                            Nds          = wb.Nds,
                            CurrId       = wb.CurrId,
                            OnValue      = wb.OnValue,
                            BasePrice    = item.AvgPrice,// item.Price,
                            PosKind      = 0,
                            PosParent    = 0,
                            DiscountKind = 0
                        });
                    }
                    db.SaveChanges();
                }
            }
        }
Example #4
0
        static public void ShowMatListByWH(BaseEntities db, WaybillList wb, DiscCards disc_card = null)
        {
            var f = new frmWhCatalog(1, disc_card);

            //   f.uc.xtraTabPage3.PageVisible = false;
            f.uc.xtraTabPage4.PageVisible             = false;
            f.uc.xtraTabPage5.PageVisible             = false;
            f.uc.xtraTabPage9.PageVisible             = false;
            f.uc.xtraTabPage11.PageVisible            = false;
            f.uc.MatListTabPage.PageVisible           = true;
            f.uc.xtraTabControl1.SelectedTabPageIndex = 4;
            f.uc.wb        = wb;
            f.uc.isMatList = true;

            if (f.ShowDialog() == DialogResult.OK)
            {
                var num = wb.WaybillDet.Count();
                foreach (var item in f.uc.custom_mat_list)
                {
                    var wbd = new WaybillDet
                    {
                        WbillId      = wb.WbillId,
                        Num          = ++num,
                        OnDate       = wb.OnDate,
                        MatId        = item.MatId,
                        WId          = item.WId,
                        Amount       = item.Amount,
                        Price        = item.Price - (item.Price * item.Discount / 100),
                        PtypeId      = item.PTypeId,
                        Discount     = item.Discount,
                        Nds          = wb.Nds,
                        CurrId       = wb.CurrId,
                        OnValue      = wb.OnValue,
                        BasePrice    = item.Price + Math.Round(item.Price.Value * wb.Nds.Value / 100, 2),
                        PosKind      = 0,
                        PosParent    = 0,
                        DiscountKind = disc_card != null ? 2 : 0,
                    };
                    db.WaybillDet.Add(wbd);
                    db.SaveChanges();

                    if (wb.WType == 16)
                    {
                        db.WMatTurn.Add(new WMatTurn()
                        {
                            SourceId = wbd.PosId,
                            PosId    = wbd.PosId,
                            WId      = wbd.WId.Value,
                            MatId    = wbd.MatId,
                            OnDate   = wbd.OnDate.Value,
                            TurnType = 3,
                            Amount   = wbd.Amount
                        });
                    }
                }
                db.SaveChanges();
            }
        }
Example #5
0
        static public void ShowMatListByWH2(BaseEntities db, WaybillList wb, int ka_id)
        {
            //Не доделано
            var f = new frmWhCatalog(1);

            f.uc.xtraTabPage4.PageVisible             = false;
            f.uc.xtraTabPage5.PageVisible             = false;
            f.uc.xtraTabPage9.PageVisible             = false;
            f.uc.MatListTabPage.PageVisible           = true;
            f.uc.xtraTabControl1.SelectedTabPageIndex = 4;
            f.uc.gridColumn49.Visible = false;
            f.uc.gridColumn51.Visible = false;
            f.uc.gridColumn52.Visible = false;
            f.uc.bar3.Visible         = false;
            f.uc.ByWhBtn.Down         = true;
            f.uc.splitContainerControl1.SplitterPosition = 0;

            f.uc.whKagentList.EditValue = ka_id;
            f.uc.whKagentList.Enabled   = false;

            f.uc.WHTreeList.DataSource = new BaseEntities().GetWhTree(DBHelper.CurrentUser.UserId, 2).Where(w => w.GType == 1).ToList();

            f.uc.GrpNameGridColumn.GroupIndex = 0;

            f.uc.wb        = wb;
            f.uc.isMatList = true;
            if (f.ShowDialog() == DialogResult.OK)
            {
                foreach (var item in f.uc.custom_mat_list)
                {
                    var wbd = db.WaybillDet.Add(new WaybillDet
                    {
                        WbillId      = wb.WbillId,
                        OnDate       = wb.OnDate,
                        MatId        = item.MatId,
                        WId          = item.WId,
                        Amount       = item.Amount,
                        Price        = item.Price,
                        Discount     = 0,
                        Nds          = wb.Nds,
                        CurrId       = wb.CurrId,
                        OnValue      = wb.OnValue,
                        BasePrice    = item.Price,
                        PosKind      = 0,
                        PosParent    = 0,
                        DiscountKind = 0
                    });
                }
                db.SaveChanges();
            }
        }
Example #6
0
        static public ReturnRemainByWH ShowRemainByWH(object old_MATID, object old_WID, int Typ)
        {
            var result = new ReturnRemainByWH();

            var f = new frmWhCatalog(1);

            f.uc.OnDateEdit.Enabled = false;

            switch (Typ)
            {
            case 1: f.Text = "Склад";    //(f.uc.WHTreeList.DataSource as List<GetWhTree_Result>).fir

                // frmWHPanel->SP_WMAT_GET->Locate("MATID",MATID, TLocateOptions()) ;
                if (f.ShowDialog() == DialogResult.OK)
                {
                    result.mat_id = (f.uc.WhMatGridView.GetFocusedRow() as WhMatGet_Result).MatId;
                    //   result.wid = (f.uc.WhRemainGridView.GetFocusedRow() as WMatGetByWh_Result).WId;
                    var remain_in_wh = DB.SkladBase().MatRemainByWh(result.mat_id, old_WID != DBNull.Value ? (int?)old_WID : 0, 0, f.uc.OnDateEdit.DateTime, "*", DBHelper.CurrentUser.UserId).ToList();
                    result.wid = remain_in_wh.Any() ? remain_in_wh.First().WId : DBHelper.WhList.FirstOrDefault(w => w.Def == 1).WId;
                }
                else
                {
                    result.mat_id = old_MATID != null ? (int)old_MATID : 0;
                    result.wid    = old_WID != DBNull.Value ? (int?)old_WID : 0;
                }
                break;

            case 2:
                if (old_MATID != null)
                {
                    using (var frm = new frmRemainOnWh(DB.SkladBase(), (int)old_MATID))
                    {
                        if (frm.ShowDialog() == DialogResult.OK)
                        {
                            result.wid    = frm.focused_wh.WId;
                            result.mat_id = (int)old_MATID;
                        }
                        else
                        {
                            result.wid = old_WID != null && old_WID != DBNull.Value ? (int?)old_WID : 0;
                        }
                    }
                }

                break;
            }

            return(result);
        }