public String insert(OrderSpecial p, String userId)
        {
            String re  = "";
            String sql = "";

            p.active = "1";
            //p.ssdata_id = "";
            int chk = 0;

            chkNull(p);
            sql = "Insert Into " + foos.table + " set " +
                  " " + foos.order_id + " = '" + p.order_id + "'" +
                  "," + foos.foods_spec_id + " = '" + p.foods_spec_id.Replace("'", "''") + "'" +
                  "," + foos.remark + " = '" + p.remark.Replace("'", "''") + "'" +
                  "," + foos.date_create + " = now()" +
                  "," + foos.active + " = '1'" +
                  "," + foos.user_create + " = '" + userId + "' " +
                  "," + foos.host_id + " = '" + p.host_id + "' " +
                  "," + foos.branch_id + " = '" + p.branch_id + "' " +
                  "," + foos.device_id + " = '" + p.device_id + "' " +
                  "," + foos.row1 + " = '" + p.row1 + "' " +
                  " ";
            try
            {
                re = conn.ExecuteNonQuery(conn.conn, sql);
            }
            catch (Exception ex)
            {
                //sql = ex.Message + " " + ex.InnerException;
                new LogFile("OrderSpecialDB -> insert " + ex.Message + " " + ex.InnerException + " \n sql " + sql);
            }

            return(re);
        }
        public String update(OrderSpecial p, String userId)
        {
            String re  = "";
            String sql = "";
            int    chk = 0;

            chkNull(p);
            sql = "Update " + foos.table + " Set " +
                  " " + foos.order_id + " = '" + p.order_id + "'" +
                  "," + foos.foods_spec_id + " = '" + p.foods_spec_id.Replace("'", "''") + "'" +
                  "," + foos.remark + " = '" + p.remark.Replace("'", "''") + "'" +
                  "," + foos.date_modi + " = now()" +
                  "," + foos.user_modi + " = '" + userId + "' " +
                  "," + foos.host_id + " = '" + p.host_id + "' " +
                  "," + foos.branch_id + " = '" + p.branch_id + "' " +
                  "," + foos.device_id + " = '" + p.device_id + "' " +
                  "," + foos.row1 + " = '" + p.row1 + "' " +

                  "Where " + foos.pkField + "='" + p.order_special_id + "'"
            ;

            try
            {
                re = conn.ExecuteNonQuery(conn.conn, sql);
            }
            catch (Exception ex)
            {
                sql = ex.Message + " " + ex.InnerException;
            }

            return(re);
        }
        private OrderSpecial setArea1(DataTable dt)
        {
            OrderSpecial dept1 = new OrderSpecial();

            if (dt.Rows.Count > 0)
            {
                dept1.order_special_id = dt.Rows[0][foos.order_special_id].ToString();
                dept1.foods_spec_id    = dt.Rows[0][foos.foods_spec_id].ToString();
            }

            return(dept1);
        }
        public OrderSpecial selectByPk1(String copId)
        {
            OrderSpecial cop1 = new OrderSpecial();
            DataTable    dt   = new DataTable();
            String       sql  = "select sex.* " +
                                "From " + foos.table + " sex " +
                                //"Left Join t_ssdata_visit ssv On ssv.ssdata_visit_id = bd.ssdata_visit_id " +
                                "Where sex." + foos.pkField + " ='" + copId + "' ";

            dt   = conn.selectData(conn.conn, sql);
            cop1 = setFoodsSpecial(dt);
            return(cop1);
        }
        public String insertFoodsSpecial(OrderSpecial p, String userId)
        {
            String re = "";

            if (p.order_special_id.Equals(""))
            {
                re = insert(p, "");
            }
            else
            {
                re = update(p, "");
            }

            return(re);
        }
        public void getlArea()
        {
            //lDept = new List<Position>();
            lfooC.Clear();
            DataTable dt = new DataTable();

            dt = selectAll();
            foreach (DataRow row in dt.Rows)
            {
                OrderSpecial itm1 = new OrderSpecial();
                itm1.order_special_id = row[foos.order_special_id].ToString();
                itm1.foods_spec_id    = row[foos.foods_spec_id].ToString();

                lfooC.Add(itm1);
            }
        }
        public List <OrderSpecial> getlFooSpecByFooId(String fooid)
        {
            //lDept = new List<Position>();
            List <OrderSpecial> lfooC1 = new List <OrderSpecial>();
            DataTable           dt     = new DataTable();

            dt = selectByFoodsId2(fooid);
            foreach (DataRow row in dt.Rows)
            {
                OrderSpecial itm1 = new OrderSpecial();
                itm1.order_special_id = row[foos.order_special_id].ToString();
                itm1.foods_spec_id    = row[foos.foods_spec_id].ToString();

                lfooC1.Add(itm1);
            }
            return(lfooC1);
        }
        private OrderSpecial setFoodsSpecial(DataTable dt)
        {
            OrderSpecial dept1 = new OrderSpecial();

            if (dt.Rows.Count > 0)
            {
                dept1.order_special_id = dt.Rows[0][foos.order_special_id].ToString();
                dept1.order_id         = dt.Rows[0][foos.order_id].ToString();
                dept1.foods_spec_id    = dt.Rows[0][foos.foods_spec_id].ToString();
                //dept1.posi_name_e = dt.Rows[0][area.posi_name_e] != null ? dt.Rows[0][area.posi_name_e].ToString() : "";
                //dept1.status_doctor = dt.Rows[0][area.status_doctor] != null ? dt.Rows[0][area.status_doctor].ToString() : "";
                dept1.remark      = dt.Rows[0][foos.remark] != null ? dt.Rows[0][foos.remark].ToString() : "";
                dept1.date_create = dt.Rows[0][foos.date_create] != null ? dt.Rows[0][foos.date_create].ToString() : "";
                dept1.date_modi   = dt.Rows[0][foos.date_modi] != null ? dt.Rows[0][foos.date_modi].ToString() : "";
                dept1.date_cancel = dt.Rows[0][foos.date_cancel] != null ? dt.Rows[0][foos.date_cancel].ToString() : "";
                dept1.user_create = dt.Rows[0][foos.user_create] != null ? dt.Rows[0][foos.user_create].ToString() : "";
                dept1.user_modi   = dt.Rows[0][foos.user_modi] != null ? dt.Rows[0][foos.user_modi].ToString() : "";
                dept1.user_cancel = dt.Rows[0][foos.user_cancel] != null ? dt.Rows[0][foos.user_cancel].ToString() : "";
                dept1.active      = dt.Rows[0][foos.active] != null ? dt.Rows[0][foos.active].ToString() : "";
                dept1.row1        = dt.Rows[0][foos.row1] != null ? dt.Rows[0][foos.row1].ToString() : "";
                //dept1.status_aircondition = dt.Rows[0][foos.status_aircondition] != null ? dt.Rows[0][foos.status_aircondition].ToString() : "";
            }
            else
            {
                dept1.order_special_id = "";
                dept1.order_id         = "";
                dept1.foods_spec_id    = "";
                //posi.dept_parent_id = "dept_parent_id";
                dept1.remark      = "";
                dept1.date_create = "";
                dept1.date_modi   = "";
                dept1.date_cancel = "";
                dept1.user_create = "";
                dept1.user_modi   = "";
                dept1.user_cancel = "";
                dept1.active      = "";
                dept1.row1        = "";
                //dept1.status_aircondition = "";
                //dept1.status_embryologist = "";
            }

            return(dept1);
        }
        private void chkNull(OrderSpecial p)
        {
            long chk = 0;

            p.date_modi   = p.date_modi == null ? "" : p.date_modi;
            p.date_cancel = p.date_cancel == null ? "" : p.date_cancel;
            p.user_create = p.user_create == null ? "" : p.user_create;
            p.user_modi   = p.user_modi == null ? "" : p.user_modi;
            p.user_cancel = p.user_cancel == null ? "" : p.user_cancel;
            p.host_id     = p.host_id == null ? "" : p.host_id;
            p.branch_id   = p.branch_id == null ? "" : p.branch_id;
            p.device_id   = p.device_id == null ? "" : p.device_id;

            p.foods_spec_id = p.foods_spec_id == null ? "" : p.foods_spec_id;
            p.order_id      = p.order_id == null ? "" : p.order_id;

            p.remark = p.remark == null ? "" : p.remark;
            p.row1   = p.row1 == null ? "" : p.row1;

            //p.host_id = long.TryParse(p.host_id, out chk) ? chk.ToString() : "0";
            //p.branch_id = long.TryParse(p.branch_id, out chk) ? chk.ToString() : "0";
            //p.device_id = long.TryParse(p.device_id, out chk) ? chk.ToString() : "0";
        }
        private void initConfig()
        {
            lfooC = new List <OrderSpecial>();
            foos  = new OrderSpecial();
            foos.order_special_id = "order_special_id";
            foos.order_id         = "order_id";
            foos.foods_spec_id    = "foods_spec_id";
            foos.active           = "active";
            foos.remark           = "remark";
            foos.row1             = "row1";
            foos.date_cancel      = "date_cancel";
            foos.date_create      = "date_create";
            foos.date_modi        = "date_modi";
            foos.user_cancel      = "user_cancel";
            foos.user_create      = "user_create";
            foos.user_modi        = "user_modi";
            foos.host_id          = "host_id";
            foos.branch_id        = "branch_id";
            foos.device_id        = "device_id";
            //foos.status_aircondition = "status_aircondition";

            foos.pkField = "order_special_id";
            foos.table   = "t_order_special";
        }
Exemple #11
0
        private void btnSave0_Click(object sender, RoutedEventArgs e)
        {
            Order order = null;

            switch (action)
            {
            case ActionState.New:
            {
                try
                {
                    Customer  customer  = (Customer)orderscmbCustomers.SelectedItem;
                    Inventory inventory = (Inventory)orderscmbInventory.SelectedItem;

                    //instantiem Order entity
                    order = new Order()
                    {
                        CustId    = customer.CustId,
                        CarId     = inventory.CarId,
                        Customer  = customer,
                        Inventory = inventory
                    };
                    //adaugam entitatea nou creata in context
                    ctx.Orders.Add(order);
                    customerOrdersViewSource.View.Refresh();
                    ctx.SaveChanges();

                    BindDataGrid();
                }
                //using System.Data;
                catch (DataException ex)
                {
                    MessageBox.Show(ex.Message);
                }
                break;
            }

            case ActionState.Edit:
            {
                OrderSpecial orderSpecial = null;
                try
                {
                    Customer  customer  = (Customer)orderscmbCustomers.SelectedItem;
                    Inventory inventory = (Inventory)orderscmbInventory.SelectedItem;
                    orderSpecial        = (OrderSpecial)ordersDataGrid.SelectedItem;
                    orderSpecial.CustId = customer.CustId;
                    orderSpecial.CarId  = inventory.CarId;

                    int curr_id     = orderSpecial.OrderId;
                    var editedOrder = ctx.Orders.FirstOrDefault(s => s.OrderId == curr_id);
                    if (editedOrder != null)
                    {
                        editedOrder.CustId    = orderSpecial.CustId;
                        editedOrder.CarId     = orderSpecial.CarId;
                        editedOrder.Customer  = customer;
                        editedOrder.Inventory = inventory;
                        customerOrdersViewSource.View.Refresh();
                        ctx.SaveChanges();
                    }
                }
                catch (DataException ex)
                {
                    MessageBox.Show(ex.Message);
                }
                // pozitionarea pe item-ul curent
                customerOrdersViewSource.View.Refresh();
                customerOrdersViewSource.View.MoveCurrentTo(orderSpecial);

                BindDataGrid();

                break;
            }

            case ActionState.Delete:
            {
                dynamic selectedOrder = ordersDataGrid.SelectedItem;
                try
                {
                    int curr_id      = ((OrderSpecial)ordersDataGrid.SelectedItem).OrderId;
                    var deletedOrder = ctx.Orders.FirstOrDefault(s => s.OrderId == curr_id);
                    if (deletedOrder != null)
                    {
                        ctx.Orders.Remove(deletedOrder);
                        ctx.SaveChanges();
                        MessageBox.Show("Order Deleted Successfully", "Message");
                        BindDataGrid();
                    }
                }
                catch (DataException ex)
                {
                    MessageBox.Show(ex.Message);
                }
                customerOrdersViewSource.View.Refresh();

                break;
            }
            }
            ordersSetAllActions(true);
            ordersFinalActions(false);
            ordersGridNextPrev(true);
            ordersComboBox(true);
            ordersTextboxBindings(true);
        }
Exemple #12
0
        private void setControl()
        {
            lfoot = new List <FoodsTopping>();
            foo   = mposC.mposDB.fooDB.getList(fooid);
            lfoot = mposC.mposDB.footpDB.getlFooSpecByFooId(foo.foods_id);
            int i2 = 0;

            foreach (FoodsTopping foot in lfoot)
            {
                //lbFoot1.Value = foot.foods_topping_name+" "+foot.price;
                initTopping(foot.foods_topping_name + " " + foot.price, foot.price, mposC.lcolorTopping[cnt], foot.foods_topping_id);
                OrderTopping ordt = new OrderTopping();
                ordt.order_topping_id = "";
                ordt.order_id         = "";
                ordt.foods_topping_id = foot.foods_topping_id;
                ordt.active           = "1";
                ordt.remark           = "";
                ordt.row1             = i2.ToString();
                ordt.date_cancel      = "";
                ordt.date_create      = "";
                ordt.date_modi        = "";
                ordt.user_cancel      = "";
                ordt.user_create      = "";
                ordt.user_modi        = "";
                ordt.host_id          = "";
                ordt.branch_id        = "";
                ordt.device_id        = "";
                ordt.qty       = "";
                ordt.price     = foot.price;
                ordt.name      = foot.foods_topping_name;
                ordt.foods_id  = foot.foods_id;
                ordt.status_ok = "";
                ordt.row_ord   = this.row;
                lordt.Add(ordt);
                cnt++;
                i2++;
            }
            lfoos = new List <FoodsSpecial>();
            lfoos = mposC.mposDB.foosDB.getlFooSpecByFooId(foo.foods_id);
            int i1 = 0;

            foreach (FoodsSpecial foot in lfoos)
            {
                //lbFoot1.Value = foot.foods_topping_name+" "+foot.price;
                initSpecial(foot.foods_spec_name, mposC.lcolorSpec[i1], foot.foods_spec_id);
                OrderSpecial ords = new OrderSpecial();
                ords.order_special_id = "";
                ords.order_id         = "";
                ords.foods_spec_id    = foot.foods_spec_id;
                ords.active           = "1";
                ords.remark           = "";
                ords.row1             = i1.ToString();
                ords.date_cancel      = "";
                ords.date_create      = "";
                ords.date_modi        = "";
                ords.user_cancel      = "";
                ords.user_create      = "";
                ords.user_modi        = "";
                ords.host_id          = "";
                ords.branch_id        = "";
                ords.device_id        = "";
                ords.name             = foot.foods_spec_name;
                ords.foods_id         = foot.foods_id;
                ords.status_ok        = "";
                ords.row_ord          = this.row;
                lords.Add(ords);
                i1++;
                cnt++;
            }
            if (ord.status_create.Equals("1"))
            {
                lbName.Value  = ord.foods_name;
                lbQty.Value   = ord.qty;
                lbPrice.Value = ord.sumPrice;
            }
            else
            {
                lbName.Value  = foo.foods_name + " " + foo.foods_name_1;
                lbQty.Value   = qty;
                lbPrice.Value = foo.foods_price;
            }

            lbRow.Value = row;

            int hei = 0;

            for (int i = 0; i < cnt; i++)
            {
                String ctl = "";
                ctl = "pnCri" + i;
                Control ctn = tpl.Controls[ctl];
                hei += ctn.Height;
            }
            //Padding padding = this.Padding;
            this.Height = pnHead.Height + hei + (cnt * 5) + 3;
            sizeNormal  = this.Size;
        }