Ejemplo n.º 1
0
        public void checkForWrongType()
        {
            Measurment measureOne = new Measurment();
            object     o          = new object();

            Assert.IsFalse(measureOne.Equals(o));
        }
Ejemplo n.º 2
0
        public List <QubitValueResult> GetQubitResultStatesById(List <IbmJobMeasurmentResult> qubitValueResults, string ResultId)
        {
            var qubitValueResult = (from ms in qubitValueResults where ms.Id == ResultId select ms).FirstOrDefault();

            if (qubitValueResult == null)
            {
                return(new List <QubitValueResult>());
            }
            if (qubitValueResult.Qasms.Count == 0)
            {
                return(new List <QubitValueResult>());
            }
            ProgramParser _parser  = new ProgramParser();
            var           commands = _parser.GetSyntaxList(_parser.GetCommandList(qubitValueResult.Qasms[0].Qasm));
            List <Qubit>  Qubits   = new List <Qubit>();

            foreach (var cmd in commands)
            {
                Measurment casted_cmd = cmd.CommandType as Measurment;
                if (casted_cmd != null)
                {
                    int qubit_index;
                    if (int.TryParse(cmd.Args[1], out qubit_index))
                    {
                        Qubits.Add(new Qubit(null, qubit_index));
                    }
                }
            }
            return(IbmComputer.GetQubitResultStates(qubitValueResult, Qubits));
        }
Ejemplo n.º 3
0
        public ActionResult Edit(Measurment model)
        {
            var message = "";

            using (FitAppContext db = new FitAppContext())
            {
                var measurment = db.Measurments.Where(m => m.Id == model.Id).FirstOrDefault();
                if (measurment != null)
                {
                    measurment.MeasurmentDate   = model.MeasurmentDate;
                    measurment.Weight           = model.Weight;
                    measurment.Height           = model.Height;
                    measurment.BicepsCircuit    = model.BicepsCircuit;
                    measurment.ThighCircuit     = model.ThighCircuit;
                    measurment.WeistCircuit     = model.WeistCircuit;
                    measurment.ChestCircuit     = model.ChestCircuit;
                    measurment.HipsCircuit      = model.HipsCircuit;
                    measurment.ShouldersCircuit = model.ShouldersCircuit;
                    measurment.ActivityLevel    = model.ActivityLevel;
                    db.SaveChanges();
                    message = "Dane zostały zaktualizowane";
                }
                else
                {
                    message = "Nie udało się zaktualizować danych";
                    return(View(model));
                }
            }
            ViewBag.Message = message;
            return(RedirectToAction("History", "Measurment"));
        }
Ejemplo n.º 4
0
        static void Main(string[] args)
        {
            Measurment c      = new Measurment();
            double     output = c.UnitConversion(Unit.FEET_TO_INCH, 12);

            Console.WriteLine("o->" + output);
        }
Ejemplo n.º 5
0
 private bool CanAddMeasurment(Measurment measurment)
 {
     if (measurment != null)
     {
         return(true);
     }
     return(false);
 }
Ejemplo n.º 6
0
        public void checkEqualse()
        {
            Measurment measureOne = new Measurment();
            double     valueOne   = measureOne.UnitConversion(Unit.FEET_TO_INCH, 12);
            double     valueTwo   = measureOne.UnitConversion(Unit.FEET_TO_INCH, 12);

            Assert.IsTrue(valueOne.Equals(valueTwo));
        }
Ejemplo n.º 7
0
 protected Measurment ConvertMeasurment(Measurment oldMeasurment)
 {
     return(new Measurment
     {
         Unit = ConversionUnit(),
         Amount = oldMeasurment.Amount * ConversionFactor()
     });
 }
Ejemplo n.º 8
0
        public void checkForWrongRefrance()
        {
            Measurment measureOne = new Measurment();

            measureOne.UnitConversion(Unit.FEET_TO_INCH, 12);
            Measurment measureTwo = new Measurment();

            measureTwo.UnitConversion(Unit.FEET_TO_INCH, 12);
            Assert.IsFalse(measureOne.Equals(measureTwo));
        }
Ejemplo n.º 9
0
        public void CanUpdate()
        {
            int count = this.MockRepository.GetAllItems().Count;
            var mes   = new Measurment {
                Id = 1, Name = "Laci", Values = "594;587;577;570;561;552;541;531;520;509;497;486;474;460;448"
            };

            this.MockRepository.AddItem(mes);


            Assert.AreEqual(3, count);
            count = this.MockRepository.GetAllItems().Count;

            Assert.AreEqual(4, count);             // Verify the expected Number post-insert
        }
Ejemplo n.º 10
0
        public ActionResult Bmi(Measurment model)
        {
            float weight = model.Weight;
            float height = model.Height / 100;

            float pattern = weight / (height * height);

            string message = "Twoje BMI wynosi " + pattern;

            ViewBag.Height  = model.Height.ToString();
            ViewBag.Weight  = model.Weight.ToString();
            ViewBag.Message = message;

            return(View(model));
        }
Ejemplo n.º 11
0
        private void AddButton_Click(object sender, EventArgs e)
        {
            bool success = true;

            for (int i = 0; i < Measurments.Count; i++)
            {
                var view        = recycler.FindViewHolderForAdapterPosition(i);
                var inputLayout = ((CachingViewHolder)view).FindCachedViewById <TextInputLayout>(Resource.Id.ValueInputLayout);
                var editText    = ((CachingViewHolder)view).FindCachedViewById <TextInputEditText>(Resource.Id.ValueEditText);
                if (editText.Text == "" || editText.Text == null)
                {
                    inputLayout.Error = "Field can't be empty!";
                    success           = false;
                }
                else if (!float.TryParse(editText.Text, out _))
                {
                    inputLayout.Error = "Field can only be number!";
                    success           = false;
                }
                else
                {
                    inputLayout.Error = null;
                    Measurments[i]    = editText.Text;
                }
            }

            if (success)
            {
                var values = new Dictionary <string, float>();

                for (int i = 0; i < Measurments.Count - 2; i++)
                {
                    values[Boiler.Template[i]] = float.Parse(Measurments[i + 2]);
                }

                var measurement = new Measurment(Boiler.Id)
                {
                    Temperature = float.Parse(Measurments[0]),
                    Level       = float.Parse(Measurments[1]),
                    Values      = values
                };

                Dismiss();
                completionSource.TrySetResult(measurement);
            }
        }
Ejemplo n.º 12
0
        static void Main(string[] args)
        {
            //Itt egy példa az adatbázis  használatára.
            var mm = new Measurment {
                Id = 1, Name = "Laci", Values = "594;587;577;570;561;552;541;531;520;509;497;486;474;460;448"
            };

            var db = new DataBaseManager();

            db.AddItem(mm);
            ICollection <Measurment> col = db.GetAllItems();

            foreach (var item in col)
            {
                Console.WriteLine(item);
            }
            Console.ReadKey();
        }
Ejemplo n.º 13
0
    protected void btnPShiftSize_Click(object sender, EventArgs e)
    {
        if (txtPSize.Text.Trim() == "" || txtMeasurementQuantity.Text.Trim() == "" || txtMeasurementPrice.Text.Trim() == "" || txtSellingPrice.Text.Trim() == "")
        {
            ScriptManager.RegisterClientScriptBlock((sender as Control), this.GetType(), "Toast Message", "toastr.error('Please fill all mendatory field');", true);
        }
        else
        {
            var sellingPrice = Convert.ToDecimal(txtSellingPrice.Text.Trim());
            var mrp          = Convert.ToDecimal(txtMeasurementPrice.Text.Trim());
            if (sellingPrice > mrp)
            {
                //ScriptManager.RegisterClientScriptBlock((sender as Control), this.GetType(), "Toast Message", "toastr.error('Selling price  can't be greater than M.R.P');", true);
                ScriptManager.RegisterClientScriptBlock((sender as Control), this.GetType(), "Toast Message", "toastr.error('Selling price cant be greater than MRP');", true);
            }
            else
            {
                List <Measurment> list = new List <Measurment>();
                var measurment         = new Measurment
                {
                    title        = txtPSize.Text,
                    quantity     = txtMeasurementQuantity.Text,
                    mrp          = txtMeasurementPrice.Text,
                    sellingPrice = txtSellingPrice.Text
                };

                if (txtPSize.Text.Trim() != "")
                {
                    lbPSizeList.Items.Add(measurment.title + "~" + measurment.quantity + "~" + measurment.mrp + "~" + measurment.sellingPrice);
                    txtPSize.Text = "";
                    txtMeasurementQuantity.Text = "";
                    txtMeasurementPrice.Text    = "";
                    txtSellingPrice.Text        = "";
                }

                if (Session["list"] != null)
                {
                    list = Session["list"] as List <Measurment>;
                }
                list.Add(measurment);
                Session["list"] = list;
            }
        }
    }
Ejemplo n.º 14
0
        public void Init()
        {
            measurments = new ObservableCollection <Measurment>
            {
                new Measurment {
                    Id = 1, Name = "Laci", Values = "594;587;577;570;561;552;541;531;520;509;497;486;474;460;448"
                },
                new Measurment {
                    Id = 2, Name = "Kati", Values = "594;587;577;570;561;552;541;531;520;509;497;486;474;460;448"
                },
                new Measurment {
                    Id = 3, Name = "Jözsi", Values = "594;587;577;570;561;552;541;531;520;509;497;486;474;460;448"
                }
            };


            // Mock the Products Repository using Moq
            mm = new Measurment {
                Id = 1, Name = "Laci", Values = "594;587;577;570;561;552;541;531;520;509;497;486;474;460;448"
            };

            Mock <IRepository> mockRepository = new Mock <IRepository>();

            mockRepository.Setup(mr => mr.UpdateItem(mm));
            mockRepository.Setup(mr => mr.DeleteItem(mm));
            mockRepository.Setup(mr => mr.GetAllItems()).Returns(measurments);

            mockRepository.Setup(mr => mr.AddItem(It.IsAny <Measurment>())).Returns(

                (Measurment target) =>
            {
                var original = mm;
                if (original == null)
                {
                    return(false);
                }

                original.Name   = target.Name;
                original.Values = target.Values;
                return(true);
            });
            this.MockRepository = mockRepository.Object;
        }
Ejemplo n.º 15
0
        //Adds new measurment to database and then refreshes the grid
        private void insertBtn_Click(object sender, RoutedEventArgs e)
        {
            if (energyTextBox.Text == "" || measurmentTextBox.Text == "")
            {
                MessageBox.Show("You need to provide all the data", "Whoops...", MessageBoxButton.OK);
                return;
            }
            Measurment newMeasurment = new Measurment()
            {
                energy      = energyTextBox.Text,
                measurment1 = measurmentTextBox.Text
            };


            db.Measurments.Add(newMeasurment);
            db.SaveChanges();
            SettingsPage.datagrid.ItemsSource = db.Measurments.ToList();
            this.Hide();
        }
Ejemplo n.º 16
0
    protected void btnPRemoveSize_Click(object sender, EventArgs e)
    {
        var list       = Session["list"] as List <Measurment>;
        var data       = lbPSizeList.SelectedItem.Value.Split('~');
        var measurment = new Measurment
        {
            title        = data[0],
            quantity     = data[1],
            mrp          = data[2],
            sellingPrice = data[3]
        };

        lbPSizeList.Items.RemoveAt(lbPSizeList.Items.IndexOf(lbPSizeList.SelectedItem));
        txtPSize.Text = "";
        txtMeasurementQuantity.Text = "";
        txtMeasurementPrice.Text    = "";
        list.Remove(measurment);
        Session["list"] = list;
    }
Ejemplo n.º 17
0
        private void AddMeasurment(Measurment measurement)
        {
            MeasurementManager.AddMeasurement(measurement);
            var tempSeries  = (LineSeries)PlotModel.Series[0];
            var levelSeries = (LineSeries)PlotModel.Series[1];

            tempSeries.Points.Add(new DataPoint(DateTimeAxis.ToDouble(measurement.DateTime), measurement.Temperature));
            levelSeries.Points.Add(new DataPoint(DateTimeAxis.ToDouble(measurement.DateTime), measurement.Level));

            if (Boiler.Template != null)
            {
                foreach (var key in Boiler.Template)
                {
                    var series = (LineSeries)PlotModel.Series.First(x => x.Title == key);
                    series.Points.Add(new DataPoint(DateTimeAxis.ToDouble(measurement.DateTime), measurement.Values[key]));
                }
            }

            PlotModel.InvalidatePlot(true);
        }
Ejemplo n.º 18
0
        public IActionResult Add()
        {
            var model          = new ProductModel();
            var measurments    = _productsRepository.GetMeasurments();
            var categories     = _categoriesRepository.GetCategories();
            var countries      = _countriesRepository.GetCountries();
            var measurmentList = new List <Measurment>();
            var categoryList   = new List <Category>();
            var countryList    = new List <Country>();

            foreach (var elem in measurments)
            {
                var measurment = new Measurment {
                    Id = elem.Id, UnitEn = elem.UnitEn, UnitAr = elem.UnitAr
                };
                measurmentList.Add(measurment);
            }

            foreach (var elem in categories)
            {
                var category = new Category {
                    Id = elem.Id, NameEn = elem.NameEn, NameAr = elem.NameAr
                };
                categoryList.Add(category);
            }

            foreach (var elem in countries)
            {
                var country = new Country {
                    Id = elem.Id, NameAr = elem.NameAr, NameEn = elem.NameEn
                };
                countryList.Add(country);
            }

            model.Measurments = measurmentList;
            model.Categories  = categoryList;
            model.Countries   = countryList;
            return(View(model));
        }
Ejemplo n.º 19
0
        public ActionResult Add(Measurment model)
        {
            if (ModelState.IsValid)
            {
                using (FitAppContext db = new FitAppContext())
                {
                    var user = db.Users.Where(m => m.Login == User.Identity.Name).FirstOrDefault();
                    if (user != null)
                    {
                        model.UserId = user.Id;
                        user.Measurments.Add(model);
                        db.SaveChanges();
                    }
                    else
                    {
                        return(RedirectToAction("Login", "User"));
                    }
                    return(RedirectToAction("History", "Measurment"));
                }
            }

            return(View(model));
        }
Ejemplo n.º 20
0
        public List <QubitValueResult> GetQubitResultStates(IbmJobMeasurmentResult qubitValueResult)
        {
            if (qubitValueResult.Qasms.Count == 0)
            {
                return(new List <QubitValueResult>());
            }
            ProgramParser _parser  = new ProgramParser();
            var           commands = _parser.GetSyntaxList(_parser.GetCommandList(qubitValueResult.Qasms[0].Qasm));
            List <Qubit>  Qubits   = new List <Qubit>();

            foreach (var cmd in commands)
            {
                Measurment casted_cmd = cmd.CommandType as Measurment;
                if (casted_cmd != null)
                {
                    int qubit_index;
                    if (int.TryParse(cmd.Args[1], out qubit_index))
                    {
                        Qubits.Add(new Qubit(null, qubit_index));
                    }
                }
            }
            return(IbmComputer.GetQubitResultStates(qubitValueResult, Qubits));
        }
Ejemplo n.º 21
0
        public ActionResult Bmr(Measurment model)
        {
            var message = "";

            using (FitAppContext db = new FitAppContext())
            {
                try
                {
                    var user = db.Users.Where(m => m.Login == User.Identity.Name).FirstOrDefault();
                    if (user != null)
                    {
                        var weight     = model.Weight;
                        var height     = model.Height;
                        int ageInYears = (Int32.Parse(DateTime.Today.ToString("yyyyMMdd")) - Int32.Parse(user.BirthDay.ToString("yyyyMMdd"))) / 10000;
                        ViewBag.Weight        = model.Weight.ToString();
                        ViewBag.Height        = model.Height.ToString();
                        ViewBag.ActivityLevel = model.ActivityLevel;
                        ViewBag.Age           = ageInYears;
                        ViewBag.Sex           = user.Sex;

                        float bmr = 0;

                        //metoda Hattisa-Benedicta
                        if (user.Sex == "Female")
                        {
                            bmr = (float)((9.6 * weight) + (1.8 * height) - (4.7 * ageInYears) + 655);
                        }
                        else if (user.Sex == "Male")
                        {
                            bmr = (float)((13.7 * weight) + (5 * height) - (6.76 * ageInYears) + 66);
                        }
                        float multipler = 0;


                        switch (model.ActivityLevel)
                        {
                        case "Znikomy":
                            multipler = (float)1.2;
                            break;

                        case "Niski":
                            multipler = (float)1.4;
                            break;

                        case "Średni":
                            multipler = (float)1.6;
                            break;

                        case "Wysoki":
                            multipler = (float)1.8;
                            break;

                        case "Bardzo Wysoki":
                            multipler = (float)2.0;
                            break;

                        default:
                            message = "Zły poziom aktywności";
                            break;
                        }
                        float activityBmr = (float)(bmr * multipler);

                        ViewBag.BMR         = bmr;
                        ViewBag.ActivityBMR = activityBmr;
                    }
                    else
                    {
                        return(RedirectToAction("Login", "User"));
                    }
                }
                catch (Exception ex)
                {
                    message = "Uzupełnij dane";
                }
            }
            ViewBag.Message = message;

            return(View(model));
        }
Ejemplo n.º 22
0
 public IActionResult Edit(int id, Measurment measurment)
 {
     db.Entry(measurment).State = Microsoft.EntityFrameworkCore.EntityState.Modified;
     db.SaveChanges();
     return(RedirectToAction("Index"));
 }
Ejemplo n.º 23
0
 public static void AddMeasurement(Measurment measurement)
 {
     SQL.Db.Insert(measurement);
 }
Ejemplo n.º 24
0
 public static void DeleteMeasurement(Measurment measurement)
 {
     SQL.Db.Delete <Measurment>(measurement.Id);
 }
Ejemplo n.º 25
0
 public IActionResult Add(Measurment measurment)
 {
     db.Measurments.Add(measurment);
     db.SaveChanges();
     return(RedirectToAction("Index"));
 }
Ejemplo n.º 26
0
    private void load_data_to_update()
    {
        try
        {
            obj = new DB();
            DataSet ds = obj.GetProductDetailforUpdation(Request.QueryString["pid"].ToString(), Session["loginid"].ToString());

            if (ds.Tables[0].Rows.Count > 0)
            {
                ddlCategory.SelectedValue    = ds.Tables[0].Rows[0]["CId"].ToString();
                ddlColor.SelectedValue       = Convert.ToString(ds.Tables[0].Rows[0]["colors"]);
                ddlRetailer.SelectedValue    = ds.Tables[0].Rows[0]["userid"].ToString();
                rbReturnPolicy.SelectedValue = ds.Tables[0].Rows[0]["IsReturnPolicy"].ToString();
                //ddlGender.SelectedValue = Convert.ToString(ds.Tables[0].Rows[0]["Gender"]);
                if (string.IsNullOrEmpty(Convert.ToString(ds.Tables[0].Rows[0]["Gender"])))
                {
                    ddlGender.SelectedValue = "0";
                    ddlGender.Visible       = false;
                }
                else
                {
                    ddlGender.Visible       = true;
                    ddlGender.SelectedValue = Convert.ToString(ds.Tables[0].Rows[0]["Gender"]);
                }
                txtBrand.Text = Convert.ToString(ds.Tables[0].Rows[0]["Brand_Title"]);
                fill_ddl_Subcategory(ds.Tables[0].Rows[0]["CId"].ToString(), ds.Tables[0].Rows[0]["Gender"].ToString());
                ddlSubCategory.Visible       = true;
                ddlSubCategory.SelectedValue = ds.Tables[0].Rows[0]["subcid"].ToString();
                if (ddlCategory.SelectedIndex == 1)
                {
                    ddlGender.Visible = true;
                    string gender = ds.Tables[0].Rows[0]["Gender"].ToString();
                    if (!string.IsNullOrEmpty(gender))
                    {
                        ddlGender.SelectedValue = gender;
                    }
                    else
                    {
                        ddlGender.SelectedIndex = 0;
                    }
                    //ddlGender.Visible = true;
                    //cbGender.ClearSelection();
                    //string[] gender = ds.Tables[0].Rows[0]["Gender"].ToString().Split(',');
                    //foreach (string s in gender)
                    //{
                    //    if (s == "M")
                    //    {
                    //        cbGender.Items[0].Selected = true;
                    //    }

                    //    if (s == "W")
                    //    {
                    //        cbGender.Items[1].Selected = true;
                    //    }

                    //    if (s == "KB")
                    //    {
                    //        cbGender.Items[2].Selected = true;
                    //    }
                    //    if (s == "KG")
                    //    {
                    //        cbGender.Items[3].Selected = true;

                    //    }
                    //}
                }
                txtPDescription.Text = ds.Tables[0].Rows[0]["PDescription"].ToString();
                txtPTitle.Text       = ds.Tables[0].Rows[0]["headertitle"].ToString();
                //txtPSellingPrice.Text = ds.Tables[0].Rows[0][1].ToString();
                //txtPCostPrice.Text = ds.Tables[0].Rows[0][2].ToString();
                //txtPDescription.Text = ds.Tables[0].Rows[0][3].ToString();
                //txtPQuantity.Text = ds.Tables[0].Rows[0][4].ToString();
                //if (ds.Tables[0].Rows[0]["MFlag"].ToString() == "1")
                //{
                //    rdbtnMeasurement.SelectedIndex = 0;
                //    pnlMeasurement.Visible = true;
                //    string s = ds.Tables[0].Rows[0]["Measurement"].ToString();
                //    string[] prodallsize = s.Split(',');
                //    lbPSizeList.Items.Clear();
                //    foreach (string prodsize in prodallsize)
                //    {
                //        lbPSizeList.Items.Add(prodsize);
                //    }
                //}
                //else
                //{
                //    rdbtnMeasurement.SelectedIndex = 1;
                //    lbPSizeList.Items.Clear();
                //    // pnlMeasurement.Visible = false;
                //}


                txtTitle1.Text = ds.Tables[0].Rows[0]["Title1"].ToString();
                txtValue1.Text = ds.Tables[0].Rows[0]["value1"].ToString();
                txtTitle2.Text = ds.Tables[0].Rows[0]["Title2"].ToString();
                txtValue2.Text = ds.Tables[0].Rows[0]["value2"].ToString();

                txtTitle3.Text  = ds.Tables[0].Rows[0]["Title3"].ToString();
                txtValue3.Text  = ds.Tables[0].Rows[0]["Value3"].ToString();
                txtTitle4.Text  = ds.Tables[0].Rows[0]["Title4"].ToString();
                txtValue4.Text  = ds.Tables[0].Rows[0]["Value4"].ToString();
                txtTitle5.Text  = ds.Tables[0].Rows[0]["Title5"].ToString();
                txtValue5.Text  = ds.Tables[0].Rows[0]["Value5"].ToString();
                txtTitle6.Text  = ds.Tables[0].Rows[0]["Title6"].ToString();
                txtValue6.Text  = ds.Tables[0].Rows[0]["Value6"].ToString();
                txtTitle7.Text  = ds.Tables[0].Rows[0]["Title7"].ToString();
                txtValue7.Text  = ds.Tables[0].Rows[0]["Value7"].ToString();
                txtTitle8.Text  = ds.Tables[0].Rows[0]["Title8"].ToString();
                txtValue8.Text  = ds.Tables[0].Rows[0]["Value8"].ToString();
                txtTitle9.Text  = ds.Tables[0].Rows[0]["Title9"].ToString();
                txtValue9.Text  = ds.Tables[0].Rows[0]["Value9"].ToString();
                txtTitle10.Text = ds.Tables[0].Rows[0]["Title10"].ToString();
                txtValue10.Text = ds.Tables[0].Rows[0]["Value10"].ToString();

                //
                var lstMeasurment = new DB().getMeasurementByProductId(Request.QueryString["pid"].ToString());
                List <Measurment> lstMeasurementList = new List <Measurment>();
                foreach (var item in lstMeasurment)
                {
                    var data       = item.Split('~');
                    var measurment = new Measurment
                    {
                        title        = data[0],
                        quantity     = data[1],
                        mrp          = data[2],
                        sellingPrice = data[3]
                    };
                    lstMeasurementList.Add(measurment);
                    lbPSizeList.Items.Add(item);
                }
                Session["list"] = lstMeasurementList;
                txtweight.Text  = Convert.ToString(ds.Tables[0].Rows[0]["weight"]);
                var dimesion = Convert.ToString(ds.Tables[0].Rows[0]["dimension"]);
                //dimesion.Replace("*", "~");
                txtL.Text = dimesion.Split('*')[0];
                txtB.Text = dimesion.Split('*')[1];
                txtH.Text = dimesion.Split('*')[2];
            }
        }
        catch (Exception ex)
        {
        }
        finally
        {
            obj = null;
        }
    }
Ejemplo n.º 27
0
    protected void btnProdSubmit_Click(object sender, EventArgs e)
    {
        try
        {
            if (
                //txtPCostPrice.Text.Trim() != ""
                txtPDescription.Text.Trim() != ""
                //&& txtPQuantity.Text.Trim() != ""
                //&& txtPSellingPrice.Text.Trim() != ""
                && txtPTitle.Text.Trim() != "" &&
                ddlCategory.SelectedIndex != 0 &&
                ddlSubCategory.SelectedIndex != 0 &&
                lbPSizeList.Items.Count > 0
                )
            {
                obj = new DB();
                obj.PMeasurementFlag = rdbtnMeasurement.SelectedIndex == 0 ? "1" : "0";
                string listitem = "";
                for (int i = 0; i < lbPSizeList.Items.Count && rdbtnMeasurement.SelectedIndex == 0; i++)
                {
                    listitem += lbPSizeList.Items[i].ToString() + ",";
                }
                if (listitem.Length > 0)
                {
                    obj.ProdAllSize = listitem.Substring(0, listitem.Length - 1);
                }
                else
                {
                    obj.ProdAllSize = null;
                }

                List <Measurment> list = new List <Measurment>();
                for (int i = 0; i < lbPSizeList.Items.Count; i++)
                {
                    var data       = lbPSizeList.Items[i].ToString().Split('~');
                    var measurment = new Measurment
                    {
                        title        = data[0],
                        quantity     = data[1],
                        mrp          = data[2],
                        sellingPrice = data[3]
                    };
                    list.Add(measurment);
                }
                Session["list"] = list;

                var brandId = obj.addNewBrand(txtBrand.Text);

                obj.EmpId          = ddlRetailer.SelectedItem.Value;                          // Session["loginid"].ToString();
                obj.ProdCP         = txtPCostPrice.Text;
                obj.BrandId        = brandId;                                                 // Convert.ToInt32(txtBrand.Text);
                obj.Color          = ddlColor.SelectedItem.Text;                              // txtColor.Text;
                obj.isReturnPolicy = rbReturnPolicy.SelectedItem.Value == "1" ? true : false; // false;
                obj.Wieght         = Convert.ToDecimal(txtweight.Text);
                obj.Dimension      = txtL.Text + "*" + txtB.Text + "*" + txtH.Text;


                obj.ProdDesc     = txtPDescription.Text;
                obj.ProdSP       = txtPSellingPrice.Text;
                obj.ProdDiscount = "0";// (((Convert.ToDecimal(txtPCostPrice.Text) - Convert.ToDecimal(txtPSellingPrice.Text)) / (Convert.ToDecimal(txtPCostPrice.Text))) * 100).ToString();
                obj.ProdQuantity = txtPQuantity.Text;
                obj.ProdTitle    = txtPTitle.Text;
                obj.ProdTitle1   = txtTitle1.Text;
                obj.ProdTitle10  = txtTitle10.Text;
                obj.ProdTitle2   = txtTitle2.Text;
                obj.ProdTitle3   = txtTitle3.Text;
                obj.ProdTitle4   = txtTitle4.Text;
                obj.ProdTitle5   = txtTitle5.Text;
                obj.ProdTitle6   = txtTitle6.Text;
                obj.ProdTitle7   = txtTitle7.Text;
                obj.ProdTitle8   = txtTitle8.Text;
                obj.ProdTitle9   = txtTitle9.Text;
                obj.ProdValue1   = txtValue1.Text;
                obj.ProdValue10  = txtValue10.Text;
                obj.ProdValue2   = txtValue2.Text;
                obj.ProdValue3   = txtValue3.Text;
                obj.ProdValue4   = txtValue4.Text;
                obj.ProdValue5   = txtValue5.Text;
                obj.ProdValue6   = txtValue6.Text;
                obj.ProdValue7   = txtValue7.Text;
                obj.ProdValue8   = txtValue8.Text;
                obj.ProdValue9   = txtValue9.Text;
                obj.ProdCId      = ddlCategory.SelectedValue;
                //string gender = "", g = "";
                string gender = "";
                if (ddlGender.SelectedValue == "0")
                {
                    gender = "";
                }
                else
                {
                    gender = ddlGender.SelectedValue;
                }


                //foreach (ListItem item in cbGender.Items)
                //{
                //    if (item.Selected)
                //    {
                //        if (item.Value == "Men")
                //            g = "M";
                //        else
                //            if (item.Value == "Women")
                //            g = "W";
                //        else
                //            if (item.Value == "KidBoy")
                //            g = "KB";
                //        else
                //            if (item.Value == "KidGirl")
                //            g = "KG";
                //        gender += g + ",";
                //    }
                //}
                //if (gender.Length > 0)
                //   gender = gender.Substring(0, gender.LastIndexOf(','));


                int s = 0;
                if (btnProdSubmit.Text == "Submit")
                {
                    s = obj.AddNewProdInfo(ddlSubCategory.SelectedValue, gender);
                    if (s > 0)
                    {
                        List <Measurment> lst = new List <Measurment>();
                        lst = Session["list"] as List <Measurment>;
                        foreach (var item in lst)
                        {
                            obj.AddProdMeasurment(s, item.title, item.quantity, item.mrp, item.sellingPrice);
                        }


                        ScriptManager.RegisterClientScriptBlock((sender as Control), this.GetType(), "Toast Message", "toastr.success('Record Added Successfully !');", true);
                        btnProdReset_Click(null, null);
                    }
                    else
                    {
                        ScriptManager.RegisterClientScriptBlock((sender as Control), this.GetType(), "Toast Message", "toastr.error('Record not Added Successfully !');", true);
                    }
                }
                else
                {
                    obj.ProdId = Request.QueryString["pid"].ToString();
                    obj.deleteMeasurement(obj.ProdId);

                    s = obj.UpdateProdInfo(ddlSubCategory.SelectedValue, gender);
                    List <Measurment> lst = new List <Measurment>();
                    lst = Session["list"] as List <Measurment>;
                    foreach (var item in lst)
                    {
                        obj.AddProdMeasurment(Convert.ToInt32(obj.ProdId), item.title, item.quantity, item.mrp, item.sellingPrice);
                    }

                    if (s > 0)
                    {
                        ScriptManager.RegisterClientScriptBlock((sender as Control), this.GetType(), "Toast Message", "toastr.success('Updation Done Successfully !');", true);
                        //  clear_all_fields();
                        btnProdReset_Click(null, null);
                        btnProdSubmit.Text = "Submit";
                    }
                    else
                    {
                        ScriptManager.RegisterClientScriptBlock((sender as Control), this.GetType(), "Toast Message", "toastr.error('Updation not Done Successfully !');", true);
                    }
                }
            }
            else
            {
                ScriptManager.RegisterClientScriptBlock((sender as Control), this.GetType(), "Toast Message", "toastr.warning('Fill all mandatory fields !');", true);
            }
        }
        catch (Exception ex)
        { }
        finally
        {
            obj = null;
        }
    }
Ejemplo n.º 28
0
 public static void UpdateMeasurement(Measurment measurement)
 {
     SQL.Db.Update(measurement);
 }
Ejemplo n.º 29
0
 public void Post([FromBody] Measurment Measurement)
 {
     _measurmentRepo.Update(Measurement);
 }
Ejemplo n.º 30
0
 public void Put(int id, [FromBody] Measurment Measurement)
 {
     Measurement.Id = id;
     _measurmentRepo.Insert(Measurement);
 }