public void TestGetFabricTypeById()
        {
            int        expectedFabricTypeId = 5;
            var        service = new FabricTypeService(carpentryWebsiteContext);
            FabricType result  = service.GetFabricTypeDetails(5);

            Assert.Equal(expectedFabricTypeId, result.FabricTypeId);
        }
 public int createFabrictype(FabricType F)
 {
     dbCon.openCon();
     cmd = new SqlCommand("insert into FabricType (fabricId,fabricType,CurrentStatus) values('" + F.fabricId + "','" + F.fabricType + "','" + F.CurrentStatus + "')", dbCon.con);
     int status = cmd.ExecuteNonQuery();
     dbCon.closeCon();
     return status;
 }
        public ActionResult DeleteConfirmed(int id)
        {
            FabricType fabricType = db.FabricType.Find(id);

            db.FabricType.Remove(fabricType);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
 public int ChangeFabricPrice(FabricType F)
 {
     dbCon.openCon();
     cmd = new SqlCommand("update FabricType set fabricPrice = '" + F.fabricPrice + "',CurrentStatus = '" + F.CurrentStatus + "' where fabricType = '" + F.fabricType + "'", dbCon.con);
     int status = cmd.ExecuteNonQuery();
     dbCon.closeCon();
     return status;
 }
        public void TestDeleteFabricTypes()
        {
            var service = new FabricTypeService(carpentryWebsiteContext);

            service.DeleteFabricType(5);
            FabricType result = service.GetFabricTypeDetails(5);

            Assert.Null(result);
        }
Beispiel #6
0
        public DataTable getFabricTypePrice(FabricType F)
        {
            dbCon.openCon();
            SqlDataAdapter da = new SqlDataAdapter("select fabricId,fabricPrice from FabricType where fabricType = '" + F.fabricType + "'", dbCon.con);

            dt = new DataTable();
            da.Fill(dt);
            dbCon.closeCon();
            return(dt);
        }
Beispiel #7
0
        public int updatefabricPrice(FabricType F)
        {
            dbCon.openCon();
            String st = "Price Updated";

            cmd = new SqlCommand("update FabricType set CurrentStatus = '" + st + "' where fabricId = '" + F.fabricId + "'", dbCon.con);
            int status = cmd.ExecuteNonQuery();

            dbCon.closeCon();
            return(status);
        }
        public ActionResult Create([Bind(Include = "Id,Name,ProdCategoryId")] FabricType fabricType)
        {
            if (ModelState.IsValid)
            {
                db.FabricType.Add(fabricType);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(fabricType));
        }
        // All Setup Keyword functions must be static. It allow to create script to automatically update the shaders with a script if code change
        static public void SetupMaterialKeywordsAndPass(Material material)
        {
            SetupBaseLitKeywords(material);
            SetupBaseLitMaterialPass(material);

            // With details map, we always use a normal map and Unity provide a default (0, 0, 1) normal map for it
            CoreUtils.SetKeyword(material, "_NORMALMAP", material.GetTexture(kNormalMap));

            // However, the tangent map flag is only bound to the presence of a tangent map
            // CoreUtils.SetKeyword(material, "_TANGENTMAP", material.GetTexture(kTangentMap));

            // For the moment, we do not support the bent normal map
            // CoreUtils.SetKeyword(material, "_BENTNORMALMAP", material.GetTexture(kBentNormalMap));

            CoreUtils.SetKeyword(material, "_MASKMAP", material.GetTexture(kMaskMap));

            // We do not support specular occlusion for the moment
            // CoreUtils.SetKeyword(material, "_ENABLESPECULAROCCLUSION", material.GetFloat(kEnableSpecularOcclusion) > 0.0f);

            CoreUtils.SetKeyword(material, "_ANISOTROPYMAP", material.GetTexture(kAnisotropyMap));
            CoreUtils.SetKeyword(material, "_DETAIL_MAP", material.GetTexture(kDetailMap));
            CoreUtils.SetKeyword(material, "_FUZZDETAIL_MAP", material.GetTexture(kFuzzDetailMap));
            CoreUtils.SetKeyword(material, "_SUBSURFACE_MASK_MAP", material.GetTexture(kSubsurfaceMaskMap));
            CoreUtils.SetKeyword(material, "_THICKNESSMAP", material.GetTexture(kThicknessMap));
            CoreUtils.SetKeyword(material, "_EMISSIVE_COLOR_MAP", material.GetTexture(kEmissiveColorMap));

            // Require and set
            bool needUV2 = (UVDetailMapping)material.GetFloat(kUVDetail) == UVDetailMapping.UV2 || (UVBaseMapping)material.GetFloat(kUVBase) == UVBaseMapping.UV2 || (UVBaseMapping)material.GetFloat(kUVEmissive) == UVBaseMapping.UV2;
            bool needUV3 = (UVDetailMapping)material.GetFloat(kUVDetail) == UVDetailMapping.UV3 || (UVBaseMapping)material.GetFloat(kUVBase) == UVBaseMapping.UV3 || (UVBaseMapping)material.GetFloat(kUVEmissive) == UVBaseMapping.UV2;

            if (needUV3)
            {
                material.DisableKeyword("_REQUIRE_UV2");
                material.EnableKeyword("_REQUIRE_UV3");
            }
            else if (needUV2)
            {
                material.EnableKeyword("_REQUIRE_UV2");
                material.DisableKeyword("_REQUIRE_UV3");
            }
            else
            {
                material.DisableKeyword("_REQUIRE_UV2");
                material.DisableKeyword("_REQUIRE_UV3");
            }

            // Fetch the fabric type
            FabricType fabricType = (FabricType)material.GetFloat(kFabricType);

            // If the material is of type cotton/wool we inject it! Otherwise it is necessarily of silk/anisotropy type (we don't inject it to save keywords)
            CoreUtils.SetKeyword(material, "_MATERIAL_FEATURE_COTTON_WOOL", fabricType == FabricType.CottonWool);
            CoreUtils.SetKeyword(material, "_MATERIAL_FEATURE_SUBSURFACE_SCATTERING", material.GetFloat(kEnableSubsurfaceScattering) > 0.0f);
            CoreUtils.SetKeyword(material, "_MATERIAL_FEATURE_TRANSMISSION", material.GetFloat(kEnableTransmission) > 0.0f);
        }
        public void TestAddFabricType()
        {
            var        service   = new FabricTypeService(carpentryWebsiteContext);
            FabricType itemToAdd = new FabricType {
                FabricTypeId = 105, Name = "Different name"
            };

            service.AddFabricType(itemToAdd);
            FabricType result = service.GetFabricTypeDetails(105);

            Assert.Equal(itemToAdd, result);
        }
        public ActionResult Edit([Bind(Include = "Id,Name,ProdCategoryId")] FabricType fabricType)
        {
            if (ModelState.IsValid)
            {
                db.Entry(fabricType).State = EntityState.Modified;
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }


            return(View(fabricType));
        }
        protected void ShaderAnisoInputGUI(Material material)
        {
            // We only have anisotropy for the silk fabric
            FabricType fabricType = (FabricType)material.GetFloat(kFabricType);

            if (fabricType == FabricType.Silk)
            {
                m_MaterialEditor.TexturePropertySingleLine(Styles.tangentMapText, tangentMap);
                m_MaterialEditor.ShaderProperty(anisotropy, Styles.anisotropyText);
                m_MaterialEditor.TexturePropertySingleLine(Styles.anisotropyMapText, anisotropyMap);
            }
        }
        // GET: FabricTypes/Details/5
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            FabricType fabricType = db.FabricType.Find(id);

            if (fabricType == null)
            {
                return(HttpNotFound());
            }
            return(View(fabricType));
        }
        public string SaveFabTypeInfo(FabricType fabricType)
        {
            string rv = "";

            try
            {
                Insert_Update_FabricType("sp_insert_FabType", "save_FabType_data", fabricType);
                rv = Operation.Success.ToString();
            }
            catch (Exception ex)
            {
                rv = ex.Message;
            }
            return(rv);
        }
        public void TestEditFabricTypes()
        {
            string     expectedName = "Different name";
            var        service      = new FabricTypeService(carpentryWebsiteContext);
            FabricType itemToAdd    = new FabricType {
                FabricTypeId = 14, Name = "Different name"
            };

            service.AddFabricType(itemToAdd);
            carpentryWebsiteContext.Entry(service.GetFabricTypeDetails(14)).State = EntityState.Detached;

            service.UpdateFabricType(new FabricType {
                FabricTypeId = 14, Name = "Different name"
            });
            FabricType result = service.GetFabricTypeDetails(14);

            Assert.Equal(expectedName, result.Name);
        }
        // GET: FabricTypes/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            FabricType fabricType = db.FabricType.Find(id);

            ViewBag.ProdCategoryId = new SelectList(db.ProdCategory.Where(x => x.BuyerInfoId == fabricType.ProdCategory.BuyerInfoId), "Id", "Name", fabricType.ProdCategoryId);

            ViewBag.BuyerInfoId = new SelectList(db.BuyerInfo.OrderBy(x => x.Name), "Id", "Name", fabricType.ProdCategory.BuyerInfoId);



            if (fabricType == null)
            {
                return(HttpNotFound());
            }
            return(View(fabricType));
        }
        public DataTable Insert_Update_FabricType(string procedure, string callname, FabricType fabricType)
        {
            _dbConn = new SqlConnection(_connectionString);
            _dbConn.Open();
            _cmd = new SqlCommand(procedure, _dbConn)
            {
                CommandType = CommandType.StoredProcedure
            };

            _cmd.Parameters.Add(new SqlParameter("@call_name", callname));
            _cmd.Parameters.Add(new SqlParameter("@p_FabTypeCode", fabricType.FabTypeCode));
            _cmd.Parameters.Add(new SqlParameter("@p_TypeHead", fabricType.TypeHead));
            _cmd.Parameters.Add(new SqlParameter("@p_Remarks", fabricType.Remarks));

            _da = new SqlDataAdapter(_cmd);
            _dt = new DataTable();
            _da.Fill(_dt);
            _dbConn.Close();
            return(_dt);
        }
        protected void dgvAddEditFabrics_ItemDataBound(object sender, DataGridItemEventArgs e)
        {
            DataGridItem item = e.Item;

            if (item.ItemIndex > -1 && item.DataItem is KeyValuePair <int, KeyValuePair <int, string> > ) // KeyValuePair<Tuple<int, int>, int>)
            {
                KeyValuePair <int, KeyValuePair <int, string> > kv = (KeyValuePair <int, KeyValuePair <int, string> >)item.DataItem;

                Literal litID             = (Literal)item.FindControl("litID");
                Literal litFabricTypeID   = (Literal)item.FindControl("litFabricTypeID");
                Literal litFabricType     = (Literal)item.FindControl("litFabricType");
                Literal litCode           = (Literal)item.FindControl("litCode");
                Literal litFabricNickName = (Literal)item.FindControl("litFabricNickName");
                Literal litFabricSupplier = (Literal)item.FindControl("litFabricSupplier");
                TextBox txtWhere          = (TextBox)item.FindControl("txtWhere");

                litFabricTypeID.Text = kv.Key.ToString();

                int        value = kv.Key;
                FabricType type  = (FabricType)value;
                litFabricType.Text = type.ToString();

                FabricCodeBO objFC = new FabricCodeBO();
                objFC.ID = kv.Value.Key;
                objFC.GetObject();

                txtWhere.Text = kv.Value.Value;

                //litVFID.Text = "0";
                litID.Text             = objFC.ID.ToString();
                litCode.Text           = objFC.Code;
                litFabricNickName.Text = objFC.NickName;
                litFabricSupplier.Text = (objFC.Supplier.HasValue && objFC.Supplier.Value > 0) ? objFC.objSupplier.Name : string.Empty;
                //    ddlfabricCodeType.Items.FindByValue(kv.Key.Item2.ToString()).Selected = true;
                //}
            }
        }
        private void btn_Conupdate_Click(object sender, EventArgs e)
        {
            try
            {
                if (grid_product.SelectedRows.Count > 0)
                {
                    if (rbn_brand.Checked)
                    {
                        AccountantDBaccess AD = new AccountantDBaccess();
                        Brand B = new Brand();
                        B.brandId = grid_product.CurrentRow.Cells["brandId"].Value.ToString();
                        int Status = AD.updateBrandPrice(B);
                        if (Status == 1)
                        {
                            MetroMessageBox.Show(this, "\n\nUpdate confirmed succesfully", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        }
                        else
                        {
                            MetroMessageBox.Show(this, "\n\nConfirmation Fail", "Fail", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        }
                        String st = "Sent To Accountant";
                        grid_product.DataSource = AD.getBrand(st);
                        //  grid_product.DataSource = AD.getSentAccountantProduct();
                    }
                    if (rbn_design.Checked)
                    {
                        AccountantDBaccess AD = new AccountantDBaccess();
                        Design             D  = new Design();
                        D.DesignId = grid_product.CurrentRow.Cells["DesignId"].Value.ToString();
                        int Status = AD.updateDesignPrice(D);
                        if (Status == 1)
                        {
                            MetroMessageBox.Show(this, "\n\nUpdate confirmed succesfully", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        }
                        else
                        {
                            MetroMessageBox.Show(this, "\n\nConfirmation Fail", "Fail", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        }


                        String st = "Sent To Accountant";
                        grid_product.DataSource = AD.getDesign(st);
                    }
                    if (rbn_fabricType.Checked)
                    {
                        AccountantDBaccess AD = new AccountantDBaccess();
                        FabricType         F  = new FabricType();
                        F.fabricId = grid_product.CurrentRow.Cells["fabricId"].Value.ToString();
                        int Status = AD.updatefabricPrice(F);
                        if (Status == 1)
                        {
                            MetroMessageBox.Show(this, "\n\nUpdate confirmed succesfully", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        }
                        else
                        {
                            MetroMessageBox.Show(this, "\n\nConfirmation Fail", "Fail", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        }

                        String st = "Sent To Accountant";
                        grid_product.DataSource = AD.getFabricType(st);
                    }
                    if (rbn_size.Checked)
                    {
                        AccountantDBaccess AD = new AccountantDBaccess();
                        ProductSize        P  = new ProductSize();
                        P.PSizeId = grid_product.CurrentRow.Cells["PSizeId"].Value.ToString();
                        int Status = AD.updateSizePrice(P);
                        if (Status == 1)
                        {
                            MetroMessageBox.Show(this, "\n\nUpdate confirmed succesfully", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        }
                        else
                        {
                            MetroMessageBox.Show(this, "\n\nConfirmation Fail", "Fail", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        }

                        String st = "Sent To Accountant";
                        grid_product.DataSource = AD.getProductSize(st);
                    }
                    if (rbn_item.Checked)
                    {
                        AccountantDBaccess AD = new AccountantDBaccess();
                        Item I = new Item();
                        I.ItemID = grid_product.CurrentRow.Cells["Item_id"].Value.ToString();
                        int Status = AD.updateItemPrice(I);
                        if (Status == 1)
                        {
                            MetroMessageBox.Show(this, "\n\nUpdate confirmed succesfully", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        }
                        else
                        {
                            MetroMessageBox.Show(this, "\n\nConfirmation Fail", "Fail", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        }

                        grid_product.DataSource = AD.getSentAccountantProduct();
                    }
                    txt_ItemType.Text   = "";
                    txt_Ftype.Text      = "";
                    txt_SalesPrice.Text = "";
                }
                else
                {
                    MetroMessageBox.Show(this, "\n\nPlease select item from datagrid", "Fail", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
            catch (SqlException)
            {
                MetroMessageBox.Show(this, "\n\nConnecton Failed", "Fail", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            catch (FormatException)
            {
                MetroMessageBox.Show(this, "\n\nInvalid Format", "Fail", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            catch (OutOfMemoryException)
            {
                MetroMessageBox.Show(this, "\n\nInsuffisent memory", "Fail", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            catch (Exception)
            {
                MetroMessageBox.Show(this, "\n\nERROR", "Fail", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
 public int Edit([FromBody] FabricType fabricType)
 {
     return(fabricTypeService.UpdateFabricType(fabricType));
 }
Beispiel #21
0
    public static Basket GetRandomBasket()
    {
        Basket basket = new Basket();

        //Determine number of garments
        int numberOfGarments = UnityEngine.Random.Range(instance.MinimumNumberOfGarments, instance.MaximumNumberOfGarments + 1);

        List <Garment> garments = new List <Garment>();

        //Generate the garments
        for (int i = 0; i < numberOfGarments;)
        {
            //Determine fabricType
            int        fabricIndex = instance.WeightedFabricIndices[UnityEngine.Random.Range(0, instance.WeightedFabricIndices.Length)];
            FabricType fabricType  = instance.LaundryGenerationParameters[fabricIndex].fabric;

            //Determine garmentType
            int         garmentTypeIndex = UnityEngine.Random.Range(0, instance.LaundryGenerationParameters[fabricIndex].garmentType.Length);
            GarmentType garmentType      = instance.LaundryGenerationParameters[fabricIndex].garmentType[garmentTypeIndex];

            //Instantiate garment
            Garment garment = null;
            switch (garmentType)
            {
            case GarmentType.Top:
                garment = new GarmentTop(new Fabric(fabricType), GarmentColor.RandomColor());
                break;

            case GarmentType.Pants:
                garment = new GarmentPants(new Fabric(fabricType), GarmentColor.RandomColor());
                break;

            case GarmentType.Sock:
                garment = new GarmentSock(new Fabric(fabricType), GarmentColor.RandomColor());
                break;

            case GarmentType.Underwear:
                garment = new GarmentUnderwear(new Fabric(fabricType), GarmentColor.RandomColor());
                break;

            case GarmentType.Dress:
                garment = new GarmentDress(new Fabric(fabricType), GarmentColor.RandomColor());
                break;

            case GarmentType.Skirt:
                garment = new GarmentSkirt(new Fabric(fabricType), GarmentColor.RandomColor());
                break;

            case GarmentType.Shirt:
                garment = new GarmentShirt(new Fabric(fabricType), GarmentColor.RandomColor());
                break;

            default:
                Debug.LogError("Unknown garment type");
                break;
            }

            i += garment.size;
            garments.Add(garment);
            if (garment is GarmentSock)
            {
                Garment otherSock = new GarmentSock((GarmentSock)garment);
                garments.Add(otherSock);
                i += otherSock.size;
            }
        }

        //Shuffle clothing to separate socks
        int n = garments.Count;

        while (n > 1)
        {
            n--;
            int     k     = UnityEngine.Random.Range(0, n + 1);
            Garment value = garments[k];
            garments[k] = garments[n];
            garments[n] = value;
        }

        foreach (Garment garment in garments)
        {
            basket.AddGarment(garment);
        }

        return(basket);
    }
Beispiel #22
0
        public ActionResult SaveFabricType(FabricType fabricType)
        {
            var res = _fabricTypeRepository.SaveFabricType(fabricType);

            return(Json(res, JsonRequestBehavior.AllowGet));
        }
Beispiel #23
0
    public Fabric(FabricType type)
    {
        switch (type)
        {
        case FabricType.Cotton:
            name                 = "Cotton";
            ironingDistance      = 15.0f;
            pattern              = null;
            grabSound            = SoundName.CottonGrab;
            dropSound            = SoundName.CottonDrop;
            washingRestrictions  = WashingRestrictions.None;
            dryingRestrictions   = DryingRestrictions.None;
            pressingRestrictions = PressingRestrictions.None;
            break;

        case FabricType.Wool:
            name                 = "Wool";
            ironingDistance      = 15.0f;
            pattern              = Resources.Load <Sprite>("Fabric Patterns/Laine_v1");
            grabSound            = SoundName.WoolGrab;
            dropSound            = SoundName.WoolDrop;
            washingRestrictions  = WashingRestrictions.HotOnly;
            dryingRestrictions   = DryingRestrictions.LowOnly;
            pressingRestrictions = PressingRestrictions.None;
            break;

        case FabricType.Synthetic:
            name                 = "Synthetic";
            ironingDistance      = 15.0f;
            pattern              = Resources.Load <Sprite>("Fabric Patterns/Synthetique_v2");
            grabSound            = SoundName.SyntheticGrab;
            dropSound            = SoundName.SyntheticDrop;
            washingRestrictions  = WashingRestrictions.ColdOnly;
            dryingRestrictions   = DryingRestrictions.None;
            pressingRestrictions = PressingRestrictions.NoIroning;
            break;

        case FabricType.Bone:
            name                 = "Bone";
            ironingDistance      = 15.0f;
            pattern              = null;
            grabSound            = SoundName.BoneGrab;
            dropSound            = SoundName.BoneDrop;
            washingRestrictions  = WashingRestrictions.NoDetergent;
            dryingRestrictions   = DryingRestrictions.None;
            pressingRestrictions = PressingRestrictions.NoIroning;
            break;

        case FabricType.Linen:
            name                 = "Linen";
            ironingDistance      = 15.0f;
            pattern              = Resources.Load <Sprite>("Fabric Patterns/Linen_material");;
            grabSound            = SoundName.LinenGrab;
            dropSound            = SoundName.LinenDrop;
            washingRestrictions  = WashingRestrictions.None;
            dryingRestrictions   = DryingRestrictions.HangDryOnly;
            pressingRestrictions = PressingRestrictions.None;
            break;

        case FabricType.Silk:
            name                 = "Silk";
            ironingDistance      = 15.0f;
            pattern              = Resources.Load <Sprite>("Fabric Patterns/Silk_material");;
            grabSound            = SoundName.SilkGrab;
            dropSound            = SoundName.SilkDrop;
            washingRestrictions  = WashingRestrictions.HandWashOnly;
            dryingRestrictions   = DryingRestrictions.HangDryOnly;
            pressingRestrictions = PressingRestrictions.NoIroning;
            break;

        case FabricType.Denim:
            name                 = "Denim";
            ironingDistance      = 15.0f;
            pattern              = Resources.Load <Sprite>("Fabric Patterns/Denim_material");;
            grabSound            = SoundName.DenimGrab;
            dropSound            = SoundName.DenimDrop;
            washingRestrictions  = WashingRestrictions.None;
            dryingRestrictions   = DryingRestrictions.LowOnly;
            pressingRestrictions = PressingRestrictions.None;
            break;
        }
    }
        private void btn_Add_Click(object sender, EventArgs e)
        {
            try
            {
                if (cmb_ProType.SelectedIndex == -1)
                {
                    MessageBox.Show("You must select a Product", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                else if (cmb_ftype.SelectedIndex == -1)
                {
                    MessageBox.Show("You must select a Fabric Type", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                else if (cmb_Brand.SelectedIndex == -1)
                {
                    MessageBox.Show("You must select a Brand", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                else if (cmb_Design.SelectedIndex == -1)
                {
                    MessageBox.Show("You must select a Design", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                else if (cmb_size.SelectedIndex == -1)
                {
                    MessageBox.Show("You must select a Size", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                else if (cmb_color.SelectedIndex == -1)
                {
                    MessageBox.Show("You must select a Color", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                else if (string.IsNullOrEmpty(txt_qty.Text) || !Regex.Match(txt_qty.Text, "^[0-9]*$").Success)
                {
                    MessageBox.Show("Invalid, Please enter Quantity correctly", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                else if (Convert.ToInt32(txt_qty.Text) <= 0)
                {
                    MetroFramework.MetroMessageBox.Show(this, "Quantity cannot be minus or zero!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                else
                {
                    SalesOrderDBaccess SD = new SalesOrderDBaccess();
                    Item I = new Item(); Brand B = new Brand(); Design D = new Design(); ProductSize P = new ProductSize(); FabricType F = new FabricType();
                    I.ProductName = cmb_ProType.Text;
                    B.brandName   = cmb_Brand.Text;
                    P.ItemType    = cmb_ProType.Text;
                    P.ProSize     = cmb_size.Text;
                    D.ItemType    = cmb_ProType.Text;
                    D.DesignType  = cmb_Design.Text;
                    F.fabricType  = cmb_ftype.Text;
                    DataView  dv = new DataView(SD.getItemPrice(I)); DataView dv1 = new DataView(SD.getBrandPrice(B)); DataView dv2 = new DataView(SD.getDesignPrice(D)); DataView dv3 = new DataView(SD.getProductSizePrice(P)); DataView dv4 = new DataView(SD.getFabricTypePrice(F));
                    DataTable dt  = dv.ToTable(true, "productPrice");
                    DataTable dt1 = dv1.ToTable(true, "brandPrice");
                    DataTable dt2 = dv2.ToTable(true, "DesignPrice");
                    DataTable dt3 = dv3.ToTable(true, "sizePrice");
                    DataTable dt4 = dv4.ToTable(true, "fabricPrice");
                    int       price;
                    if (cmb_color.Text == "White")
                    {
                        price = (Convert.ToInt32(dt.Rows[0]["productPrice"].ToString()) + Convert.ToInt32(dt1.Rows[0]["brandPrice"].ToString()) + Convert.ToInt32(dt2.Rows[0]["DesignPrice"].ToString()) + Convert.ToInt32(dt3.Rows[0]["sizePrice"].ToString()) + Convert.ToInt32(dt4.Rows[0]["fabricPrice"].ToString()) + 250) * Convert.ToInt32(txt_qty.Text);
                    }
                    else
                    {
                        price = (Convert.ToInt32(dt.Rows[0]["productPrice"].ToString()) + Convert.ToInt32(dt1.Rows[0]["brandPrice"].ToString()) + Convert.ToInt32(dt2.Rows[0]["DesignPrice"].ToString()) + Convert.ToInt32(dt3.Rows[0]["sizePrice"].ToString()) + Convert.ToInt32(dt4.Rows[0]["fabricPrice"].ToString()) + 100) * Convert.ToInt32(txt_qty.Text);
                    }


                    this.datagrid_add.Rows.Add(cmb_ProType.Text, cmb_ftype.Text, cmb_Brand.Text, cmb_Design.Text, cmb_size.Text, cmb_color.Text, txt_qty.Text, price);
                    //////////////////////////////////////////
                    DataTable dtt  = dv.ToTable(true, "Item_id");
                    DataTable dtt5 = dv1.ToTable(true, "brandId");
                    DataTable dtt6 = dv2.ToTable(true, "DesignId");
                    DataTable dtt7 = dv3.ToTable(true, "PSizeId");
                    DataTable dtt8 = dv4.ToTable(true, "fabricId");


                    SaleDetails SD2 = new SaleDetails();
                    SD2.sd_id            = SD.GetSDId();
                    SD2.sale_id          = txt_SOno.Text;
                    SD2.sd_Product       = cmb_ProType.Text;
                    SD2.Item_id          = dtt.Rows[0]["Item_id"].ToString();
                    SD2.brandId          = dtt5.Rows[0]["brandId"].ToString();
                    SD2.DesignId         = dtt6.Rows[0]["DesignId"].ToString();
                    SD2.fabricId         = dtt7.Rows[0]["PSizeId"].ToString();
                    SD2.PSizeId          = dtt8.Rows[0]["fabricId"].ToString();
                    SD2.sd_qty           = txt_qty.Text;
                    SD2.sd_Product_price = price.ToString();

                    int status = SD.createSale_details(SD2);
                }
            }
            catch (SqlException)
            {
                MetroMessageBox.Show(this, "\n\nConnecton Failed", "Fail", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            catch (FormatException)
            {
                MetroMessageBox.Show(this, "\n\nInvalid Format", "Fail", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            catch (OutOfMemoryException)
            {
                MetroMessageBox.Show(this, "\n\nInsuffisent memory", "Fail", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            catch (Exception)
            {
                MetroMessageBox.Show(this, "\n\nERROR", "Fail", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
 public int Create([FromBody] FabricType fabricType)
 {
     return(fabricTypeService.AddFabricType(fabricType));
 }