Exemplo n.º 1
0
        private void Categoriesbutton_Click(object sender, EventArgs e)
        {
            var msender = sender as POSButton;
            var gi      = msender.ItemsID;

            pnlItems.Controls.Clear();
            var items = db.POS_Items.Where(w => w.Category_ID == gi && w.Branch_ID == Settings.CurrentBranch_ID).ToList();

            foreach (var item in items)
            {
                POSButton newButton = new POSButton();
                newButton.Size         = new System.Drawing.Size(83, 54);
                newButton.ItemsID      = item.ID;
                newButton.Text         = item.ItemName + ((bool)item.ContainSizes ? "" : " (" + item.Price + ")");
                newButton.ItemsName    = item.ItemName;
                newButton.Price        = item.Price;
                newButton.Click       += new EventHandler(Itemsbutton_Click);
                newButton.ContainSizes = item.ContainSizes;
                newButton.ItemService  = item.ItemService;
                pnlItems.Controls.Add(newButton);
            }
        }
Exemplo n.º 2
0
        private void Itemsbutton_Click(object sender, EventArgs e)
        {
            pnlSizes.Controls.Clear();

            var msender = sender as POSButton;

            if ((bool)msender.ContainSizes)
            {
                var ItemsID = msender.ItemsID;

                var mSizes = (from mis in db.POS_ItemsSizes
                              join ms in db.POS_Sizes on mis.Size_ID equals ms.ID
                              where mis.Branch_ID == Settings.CurrentBranch_ID
                              select new { mis.Size_ID, ms.SizeName, mis.Price, mis.Item_ID }).Where(w => w.Item_ID == ItemsID).ToList();

                foreach (var mSize in mSizes)
                {
                    POSButton newButton = new POSButton();
                    newButton.Size      = new System.Drawing.Size(83, 54);
                    newButton.ItemsID   = (long)mSize.Item_ID;
                    newButton.SizeID    = mSize.Size_ID;
                    newButton.Text      = mSize.SizeName + " (" + mSize.Price + ")";
                    newButton.ItemsName = msender.ItemsName;
                    newButton.SizeName  = mSize.SizeName;
                    newButton.Price     = mSize.Price;

                    newButton.Click += new EventHandler(Sizebutton_Click);

                    pnlSizes.Controls.Add(newButton);
                }
            }
            else
            {
                AddRow(msender, false);
            }
        }
Exemplo n.º 3
0
        private void frmOrders_Load(object sender, EventArgs e)
        {
            Settings.CreateShift();

            TreeItems.KeyFieldName    = "ID";
            TreeItems.ParentFieldName = "PerantID";

            // Here we create a DataTable with four columns.
            DataColumn dc = new DataColumn("ID", typeof(long));

            dc.AutoIncrement     = true;
            dc.AutoIncrementSeed = 1;
            dc.AutoIncrementStep = 1;
            Itemsdt.Columns.Add(dc);

            Itemsdt.Columns.Add("ItemID", typeof(long));
            Itemsdt.Columns.Add("SizeID", typeof(long));
            Itemsdt.Columns.Add("Qty", typeof(double));
            Itemsdt.Columns.Add("ItemName", typeof(string));
            Itemsdt.Columns.Add("Note", typeof(string));
            Itemsdt.Columns.Add("Price", typeof(double));
            Itemsdt.Columns.Add("PriceValue", typeof(double));
            Itemsdt.Columns.Add("Discount", typeof(double));
            Itemsdt.Columns.Add("isPrint", typeof(bool));
            Itemsdt.Columns.Add("isDelete", typeof(bool));
            Itemsdt.Columns.Add("PerantID", typeof(long));

            Itemsdt.Columns.Add("UserCreate", typeof(long));
            Itemsdt.Columns.Add("UserLastModified", typeof(long));
            Itemsdt.Columns.Add("CreationDate", typeof(DateTime));
            Itemsdt.Columns.Add("LastModified", typeof(DateTime));
            Itemsdt.Columns.Add("Deleterow", typeof(string));
            Itemsdt.Columns.Add("UserDelete", typeof(long));
            //Itemsdt.Columns.Add("Orderid", typeof(long));
            TreeItems.DataSource = Itemsdt;
            //-----------------------------------------------------------------------------

            var tabledt = db.POS_Tables.Where(c => c.Branch_ID == Settings.CurrentBranch_ID).ToList();

            lookUpTables.Properties.DataSource    = tabledt;
            lookUpTables.Properties.DisplayMember = "TableName";
            lookUpTables.Properties.ValueMember   = "ID";
            lookUpTables.Properties.Columns.Add(new LookUpColumnInfo("TableCode", "TableCode", 20));
            lookUpTables.Properties.Columns.Add(new LookUpColumnInfo("TableName", "TableName", 100));
            //lookUpTables.Properties.BestFitMode = BestFitMode.BestFitResizePopup;
            //lookUpTables.Properties.SearchMode = SearchMode.AutoComplete;



            LookUpCustomers.Properties.ValueMember   = "ID";
            LookUpCustomers.Properties.DisplayMember = "CustomerName";

            GridColumn columnc = LookUpCustomers.Properties.View.Columns.AddField("ID");

            columnc.Visible = false;
            columnc         = LookUpCustomers.Properties.View.Columns.AddField("CustomerCode");
            columnc.Visible = true;
            columnc         = LookUpCustomers.Properties.View.Columns.AddField("CustomerName");
            columnc.Visible = true;

            //searchLookUpEdit1.Properties.View.Columns.AddField("AreaName").Visible = true;
            LookUpCustomers.Properties.TextEditStyle = TextEditStyles.Standard;
            FilllookupCustomers();


            var tabledt3 = db.Employees.Where(c => c.Branch_ID == Settings.CurrentBranch_ID).ToList();

            lookUpDelivery.Properties.DataSource    = tabledt3;
            lookUpDelivery.Properties.DisplayMember = "EmployeeName";
            lookUpDelivery.Properties.ValueMember   = "ID";
            lookUpDelivery.Properties.Columns.Add(new LookUpColumnInfo("EmployeeCode", "EmployeeCode", 20));
            lookUpDelivery.Properties.Columns.Add(new LookUpColumnInfo("EmployeeName", "EmployeeName", 100));


            var tabledt4 = db.POS_LKUPOrderType.ToList();

            cmbOrderType.DataSource    = tabledt4;
            cmbOrderType.DisplayMember = "OrderTypeName";
            cmbOrderType.ValueMember   = "ID";



            LookUpOrders.Properties.ValueMember   = "ID";
            LookUpOrders.Properties.DisplayMember = "OrderNo";
            GridColumn column = LookUpOrders.Properties.View.Columns.AddField("ID");

            column.Visible = false;
            column         = LookUpOrders.Properties.View.Columns.AddField("OrderNo");
            column.Visible = true;
            column         = LookUpOrders.Properties.View.Columns.AddField("CreationDate");
            column.Visible = true;
            LookUpOrders.Properties.TextEditStyle = TextEditStyles.Standard;

            FillLookupOrder();

            int Margin = 5;
            int left   = 0;

            var catogry = db.POS_ItemsCategories.Where(c => c.Branch_ID == Settings.CurrentBranch_ID).ToList();

            foreach (var VARIABLE in catogry)
            {
                POSButton newButton = new POSButton();

                newButton.Size    = new System.Drawing.Size(83, 54);
                newButton.ItemsID = VARIABLE.ID;
                newButton.Text    = VARIABLE.CategoryName;
                newButton.Click  += new EventHandler(Categoriesbutton_Click);

                newButton.Left = left;
                left          += newButton.Width + Margin;
                pnlPOS_ItemsCategories.Controls.Add(newButton);
            }

            pnlPOS_ItemsCategories.HorizontalScroll.Maximum = left - 500;


            btnClear_Click(null, null);
        }
Exemplo n.º 4
0
        void AddRow(POSButton sender, bool isSize)
        {
            int par = 0;

            if (sender.ItemService != null && TreeItems.FocusedNode != null)
            {
                if ((bool)sender.ItemService && TreeItems.FocusedNode.Level == 0)
                {
                    var dd = TreeItems.FocusedNode.GetValue("ID");
                    //par = (int)dd;
                    int.TryParse(dd.ToString(), out par);
                    if ((bool)TreeItems.FocusedNode["isPrint"])
                    {
                        return;
                    }
                }
            }
            var     sName = isSize ? " - " + sender.SizeName : "";
            DataRow dr    = null;

            if (Itemsdt.Rows.Count > 0)
            {
                try
                {
                    var drr = Itemsdt.AsEnumerable().Where(r => !((bool)r["isPrint"] && ((long)r["ItemID"]) == sender.ItemsID)).First();
                    //////
                    if (drr != null)
                    {
                        if (sender.ItemService != null && !(bool)sender.ItemService)
                        {
                            if (sender.SizeID != null)
                            {
                                dr = Itemsdt.AsEnumerable()
                                     .First(
                                    r =>
                                    (r["ItemID"]).Equals(sender.ItemsID) &&
                                    (r["SizeID"]).Equals(sender.SizeID) &&
                                    ((bool)r["isPrint"]).Equals(false));
                            }
                            else
                            {
                                dr = Itemsdt.AsEnumerable()
                                     .First(
                                    r =>
                                    (r["ItemID"]).Equals(sender.ItemsID) &&
                                    ((bool)r["isPrint"]).Equals(false));
                            }
                        }
                        else
                        {
                            //par
                            if (sender.SizeID != null)
                            {
                                if (par != null)
                                {
                                    dr = Itemsdt.AsEnumerable()
                                         .First(
                                        r =>
                                        (r["ItemID"]).Equals(sender.ItemsID) &&
                                        (r["SizeID"]).Equals(sender.SizeID) &&
                                        ((bool)r["isPrint"]).Equals(false) &&
                                        (r["PerantID"]).Equals(par)
                                        );
                                }
                                else
                                {
                                    dr = Itemsdt.AsEnumerable()
                                         .First(
                                        r =>
                                        (r["ItemID"]).Equals(sender.ItemsID) &&
                                        (r["SizeID"]).Equals(sender.SizeID) &&
                                        ((bool)r["isPrint"]).Equals(false)
                                        );
                                }
                            }
                            else
                            {
                                if (par != null)
                                {
                                    dr = Itemsdt.AsEnumerable()
                                         .First(
                                        r =>
                                        (r["ItemID"]).Equals(sender.ItemsID) &&
                                        ((bool)r["isPrint"]).Equals(false) &&
                                        (r["PerantID"]).Equals(par));
                                }
                                else
                                {
                                    dr = Itemsdt.AsEnumerable()
                                         .First(
                                        r =>
                                        (r["ItemID"]).Equals(sender.ItemsID) &&
                                        ((bool)r["isPrint"]).Equals(false));
                                }
                            }
                        }
                    }
                }
                catch (Exception)
                {
                }
            }

            if (dr == null)
            {
                Itemsdt.Rows.Add(
                    null,                     //"ID"
                    sender.ItemsID,           //"ItemID"
                    sender.SizeID,            //"SizeID"
                    1,                        //"Qty"
                    sender.ItemsName + sName, //"ItemName"
                    string.Empty,             // Note
                    sender.Price,             //"Price"
                    sender.Price * 1,         //"Value"
                    0.0,                      // Discount  ,
                    false,                    //"isPrint"
                    false,                    //"isDelete"
                    par,                      //"PerantID"
                    Settings.CurrentUser_ID,  //"UserCreate"
                    Settings.CurrentUser_ID,  //"UserLastModified"
                    DateTime.Now,             //"CreationDate"
                    DateTime.Now,             //"LastModified"
                    null                      // UserDelete
                    //,Orderid
                    );
            }
            else
            {
                dr["Qty"]              = (double)dr["Qty"] + 1;
                dr["PriceValue"]       = (double)dr["Qty"] * (double)dr["Price"];
                dr["LastModified"]     = DateTime.Now;
                dr["UserLastModified"] = Settings.CurrentUser_ID;
            }
            grdSummary();
            TreeItems.FocusedNode = null;
        }