public static void InsertTERRY(Sale_B_TERRY _Sale_B_TERRY, int SaleId, string User)
        {
            DbCommand command = Catalog_Access.CreateCommand();
            command.CommandText = "sp_insertSale_B_TERRY";

            DbParameter param;

            param = command.CreateParameter();
            param.ParameterName = "@SaleId";
            param.Value = SaleId;
            param.DbType = DbType.Int32;
            command.Parameters.Add(param);

            param = command.CreateParameter();
            param.ParameterName = "@CONSMP";
            param.Value = _Sale_B_TERRY.CONSMP;
            param.DbType = DbType.Decimal;
            command.Parameters.Add(param);

            param = command.CreateParameter();
            param.ParameterName = "@UNIT";
            param.Value = _Sale_B_TERRY.UNIT;
            param.DbType = DbType.Int32;
            command.Parameters.Add(param);

            param = command.CreateParameter();
            param.ParameterName = "@COURSE";
            param.Value = _Sale_B_TERRY.COURSE;
            param.DbType = DbType.String;
            command.Parameters.Add(param);

            param = command.CreateParameter();
            param.ParameterName = "@GAUGE";
            param.Value = _Sale_B_TERRY.GAUGE;
            param.DbType = DbType.Decimal;
            command.Parameters.Add(param);

            param = command.CreateParameter();
            param.ParameterName = "@GSM";
            param.Value = _Sale_B_TERRY.GSM;
            param.DbType = DbType.Decimal;
            command.Parameters.Add(param);

            param = command.CreateParameter();
            param.ParameterName = "@LENGTH";
            param.Value = _Sale_B_TERRY.LENGTH;
            param.DbType = DbType.Decimal;
            command.Parameters.Add(param);

            param = command.CreateParameter();
            param.ParameterName = "@DYEDBLEACHED";
            param.Value = _Sale_B_TERRY.DYEDBLEACHED;
            param.DbType = DbType.Decimal;
            command.Parameters.Add(param);

            param = command.CreateParameter();
            param.ParameterName = "@YARN1";
            param.Value = _Sale_B_TERRY.YARN1;
            param.DbType = DbType.Int32;
            command.Parameters.Add(param);

            param = command.CreateParameter();
            param.ParameterName = "@YARN1HD";
            param.Value = _Sale_B_TERRY.YARN1HD;
            param.DbType = DbType.Int32;
            command.Parameters.Add(param);

            param = command.CreateParameter();
            param.ParameterName = "@YARN2";
            param.Value = _Sale_B_TERRY.YARN2;
            param.DbType = DbType.Int32;
            command.Parameters.Add(param);

            param = command.CreateParameter();
            param.ParameterName = "@YARN2HD";
            param.Value = _Sale_B_TERRY.YARN2HD;
            param.DbType = DbType.Int32;
            command.Parameters.Add(param);

            param = command.CreateParameter();
            param.ParameterName = "@YARN3";
            param.Value = _Sale_B_TERRY.YARN3;
            param.DbType = DbType.Int32;
            command.Parameters.Add(param);

            param = command.CreateParameter();
            param.ParameterName = "@YARN3HD";
            param.Value = _Sale_B_TERRY.YARN3HD;
            param.DbType = DbType.Int32;
            command.Parameters.Add(param);

            param = command.CreateParameter();
            param.ParameterName = "@BRAND1";
            param.Value = _Sale_B_TERRY.BRAND1;
            param.DbType = DbType.Int32;
            command.Parameters.Add(param);

            param = command.CreateParameter();
            param.ParameterName = "@BRAND2";
            param.Value = _Sale_B_TERRY.BRAND2;
            param.DbType = DbType.Int32;
            command.Parameters.Add(param);

            param = command.CreateParameter();
            param.ParameterName = "@BRAND3";
            param.Value = _Sale_B_TERRY.BRAND3;
            param.DbType = DbType.Int32;
            command.Parameters.Add(param);

            param = command.CreateParameter();
            param.ParameterName = "@RATE1";
            param.Value = _Sale_B_TERRY.RATE1;
            param.DbType = DbType.Decimal;
            command.Parameters.Add(param);

            param = command.CreateParameter();
            param.ParameterName = "@RATE2";
            param.Value = _Sale_B_TERRY.RATE2;
            param.DbType = DbType.Decimal;
            command.Parameters.Add(param);

            param = command.CreateParameter();
            param.ParameterName = "@RATE3";
            param.Value = _Sale_B_TERRY.RATE3;
            param.DbType = DbType.Decimal;
            command.Parameters.Add(param);

            param = command.CreateParameter();
            param.ParameterName = "@CreatedBy";
            param.Value = User;
            param.DbType = DbType.String;
            command.Parameters.Add(param);

            Catalog_Access.ExecuteNonQuery(command);
        }
        public static string Insert(Sale _Sale, Sale_B_KNITTED _Sale_B_KNITTED, List<Sale_B_WOVEN> list_Sale_B_WOVEN, Sale_B_NONWOVEN _Sale_B_NONWOVEN, Sale_B_TERRY _Sale_B_TERRY, Sale_B_KNITWRIST _Sale_B_KNITWRIST, Sale_B_LEATHER _Sale_B_LEATHER)
        {
            _Sale.ID = InsertSale(_Sale);

            if (_Sale.ID > 0)
            {

                if (_Sale_B_KNITTED != null)
                    InsertKNITTED(_Sale_B_KNITTED, _Sale.ID, _Sale.CreatedBy);
                if (list_Sale_B_WOVEN != null)
                    foreach (Sale_B_WOVEN _Sale_B_WOVEN in list_Sale_B_WOVEN)
                        InsertWOVEN(_Sale_B_WOVEN, _Sale.ID, _Sale.CreatedBy);

                if (_Sale_B_NONWOVEN != null)
                    InsertNONWOVEN(_Sale_B_NONWOVEN, _Sale.ID, _Sale.CreatedBy);
                if (_Sale_B_TERRY != null)
                    InsertTERRY(_Sale_B_TERRY, _Sale.ID, _Sale.CreatedBy);
                if (_Sale_B_KNITWRIST != null)
                    InsertKNITWRIST(_Sale_B_KNITWRIST, _Sale.ID, _Sale.CreatedBy);
                if (_Sale_B_LEATHER != null)
                    InsertLEATHER(_Sale_B_LEATHER, _Sale.ID, _Sale.CreatedBy);

                return "0";
            }
            else
            {
                return "1";
            }
        }
        public string Submit(Sale _Sale, Sale_B_KNITTED _Sale_B_KNITTED, List<Sale_B_WOVEN> list_Sale_B_WOVEN, Sale_B_NONWOVEN _Sale_B_NONWOVEN, Sale_B_TERRY _Sale_B_TERRY, Sale_B_KNITWRIST _Sale_B_KNITWRIST, Sale_B_LEATHER _Sale_B_LEATHER)
        {
            string msg = "";

            if (_Sale.ID == 0)
            {
                _Sale.CreatedBy = Session["User"].ToString();
                msg = Sale_DA.Insert(_Sale, _Sale_B_KNITTED, list_Sale_B_WOVEN, _Sale_B_NONWOVEN, _Sale_B_TERRY, _Sale_B_KNITWRIST, _Sale_B_LEATHER);

            }
            else
            {
                _Sale.UpdatedBy = Session["User"].ToString();
                msg = Sale_DA.Update(_Sale, _Sale_B_KNITTED, list_Sale_B_WOVEN, _Sale_B_NONWOVEN, _Sale_B_TERRY, _Sale_B_KNITWRIST, _Sale_B_LEATHER);
            }

            return msg;
        }
        public static string Update(Sale _Sale, Sale_B_KNITTED _Sale_B_KNITTED, List<Sale_B_WOVEN> list_Sale_B_WOVEN, Sale_B_NONWOVEN _Sale_B_NONWOVEN, Sale_B_TERRY _Sale_B_TERRY, Sale_B_KNITWRIST _Sale_B_KNITWRIST, Sale_B_LEATHER _Sale_B_LEATHER)
        {
            if (UpdateSale(_Sale) == "4")
            {
                if (_Sale_B_KNITTED != null)
                    if (_Sale_B_KNITTED.Id == 0)
                        InsertKNITTED(_Sale_B_KNITTED, _Sale.ID, _Sale.UpdatedBy);
                    else
                        UpdateKNITTED(_Sale_B_KNITTED, _Sale.ID, _Sale.UpdatedBy);

                if (list_Sale_B_WOVEN != null)
                    foreach (Sale_B_WOVEN _Sale_B_WOVEN in list_Sale_B_WOVEN)
                    {
                        if (_Sale_B_WOVEN.Id == 0)
                            InsertWOVEN(_Sale_B_WOVEN, _Sale.ID, _Sale.UpdatedBy);
                        else
                            UpdateWOVEN(_Sale_B_WOVEN, _Sale.ID, _Sale.UpdatedBy);
                    }
                if (_Sale_B_NONWOVEN != null)
                    if (_Sale_B_NONWOVEN.Id == 0)
                        InsertNONWOVEN(_Sale_B_NONWOVEN, _Sale.ID, _Sale.UpdatedBy);
                    else
                        UpdateNONWOVEN(_Sale_B_NONWOVEN, _Sale.ID, _Sale.UpdatedBy);

                if (_Sale_B_TERRY != null)
                    if (_Sale_B_TERRY.Id == 0)
                        InsertTERRY(_Sale_B_TERRY, _Sale.ID, _Sale.UpdatedBy);
                    else
                        UpdateTERRY(_Sale_B_TERRY, _Sale.ID, _Sale.UpdatedBy);

                if (_Sale_B_KNITWRIST != null)
                    if (_Sale_B_KNITWRIST.Id == 0)
                        InsertKNITWRIST(_Sale_B_KNITWRIST, _Sale.ID, _Sale.UpdatedBy);
                    else
                        UpdateKNITWRIST(_Sale_B_KNITWRIST, _Sale.ID, _Sale.UpdatedBy);

                if (_Sale_B_LEATHER != null)
                    if (_Sale_B_LEATHER.Id == 0)
                        InsertLEATHER(_Sale_B_LEATHER, _Sale.ID, _Sale.UpdatedBy);
                    else
                        UpdateLEATHER(_Sale_B_LEATHER, _Sale.ID, _Sale.UpdatedBy);

                return "4";
            }
            else
            {
                return "1";
            }
        }
        public Sale_B_TERRY GetTERRY(int SaleId)
        {
            Sale_B_TERRY _Sale_B_TERRY = null;

            DataTable dt = Sale_DA.GetTERRY(SaleId);

            foreach (DataRow row in dt.Rows)
            {
                _Sale_B_TERRY = new Sale_B_TERRY();

                _Sale_B_TERRY.Id = int.Parse(row["Id"].ToString());

                if (row["UNIT"].ToString() != "")
                    _Sale_B_TERRY.UNIT = int.Parse(row["UNIT"].ToString());
                if (row["CONSMP"].ToString() != "")
                    _Sale_B_TERRY.CONSMP = float.Parse(row["CONSMP"].ToString());
                _Sale_B_TERRY.COURSE = row["COURSE"].ToString();
                if (row["GAUGE"].ToString() != "")
                    _Sale_B_TERRY.GAUGE = float.Parse(row["GAUGE"].ToString());
                if (row["GSM"].ToString() != "")
                    _Sale_B_TERRY.GSM = float.Parse(row["GSM"].ToString());
                if (row["LENGTH"].ToString() != "")
                    _Sale_B_TERRY.LENGTH = float.Parse(row["LENGTH"].ToString());
                if (row["DYEDBLEACHED"].ToString() != "")
                    _Sale_B_TERRY.DYEDBLEACHED = float.Parse(row["DYEDBLEACHED"].ToString());

                if (row["YARN1"].ToString() != "")
                    _Sale_B_TERRY.YARN1 = int.Parse(row["YARN1"].ToString());
                if (row["YARN1HD"].ToString() != "")
                    _Sale_B_TERRY.YARN1HD = int.Parse(row["YARN1HD"].ToString());
                if (row["YARN2"].ToString() != "")
                    _Sale_B_TERRY.YARN2 = int.Parse(row["YARN2"].ToString());
                if (row["YARN2HD"].ToString() != "")
                    _Sale_B_TERRY.YARN2HD = int.Parse(row["YARN2HD"].ToString());
                if (row["YARN3"].ToString() != "")
                    _Sale_B_TERRY.YARN3 = int.Parse(row["YARN3"].ToString());
                if (row["YARN3HD"].ToString() != "")
                    _Sale_B_TERRY.YARN3HD = int.Parse(row["YARN3HD"].ToString());

                if (row["BRAND1"].ToString() != "")
                    _Sale_B_TERRY.BRAND1 = int.Parse(row["BRAND1"].ToString());
                if (row["BRAND2"].ToString() != "")
                    _Sale_B_TERRY.BRAND2 = int.Parse(row["BRAND2"].ToString());
                if (row["BRAND3"].ToString() != "")
                    _Sale_B_TERRY.BRAND3 = int.Parse(row["BRAND3"].ToString());

                if (row["RATE1"].ToString() != "")
                    _Sale_B_TERRY.RATE1 = float.Parse(row["RATE1"].ToString());
                if (row["RATE2"].ToString() != "")
                    _Sale_B_TERRY.RATE2 = float.Parse(row["RATE2"].ToString());
                if (row["RATE3"].ToString() != "")
                    _Sale_B_TERRY.RATE3 = float.Parse(row["RATE3"].ToString());

            }
            return _Sale_B_TERRY;
        }