Exemplo n.º 1
0
        public int DeleteQCPara(QCParameters objQCParameters)
        {
            int result = 0;

            using (IDbConnection connection = OpenConnection(dataConnection))
            {
                string sql = @" Update QCParam Set isActive=0 WHERE QCParamId=@QCParamId";
                try
                {
                    var id = connection.Execute(sql, objQCParameters);
                    objQCParameters.QCParamId = id;
                    result = 0;
                    InsertLoginHistory(dataConnection, objQCParameters.CreatedBy, "Delete", "QCParam", id.ToString(), "0");
                }
                catch (SqlException ex)
                {
                    int err = ex.Errors.Count;
                    if (ex.Errors.Count > 0)  // Assume the interesting stuff is in the first error
                    {
                        switch (ex.Errors[0].Number)
                        {
                        case 547:      // Foreign Key violation
                            result = 1;
                            break;

                        default:
                            result = 2;
                            break;
                        }
                    }
                }

                return(result);
            }
        }
Exemplo n.º 2
0
        public QCParameters InsertQCPara(QCParameters objQCParameters)
        {
            using (IDbConnection connection = OpenConnection(dataConnection))
            {
                var result = new QCParameters();

                IDbTransaction trn = connection.BeginTransaction();

                string sql = @"INSERT INTO QCParam (QCParamName,QCParaId,QCRefNo,CreatedBy,CreatedDate,OrganizationId,isActive) 
                              VALUES(@QCParamName,@QCParaId,@QCRefNo,@CreatedBy,@CreatedDate,@OrganizationId,1);
                              SELECT CAST(SCOPE_IDENTITY() as int)";

                try
                {
                    int internalid = DatabaseCommonRepository.GetInternalIDFromDatabase(connection, trn, typeof(QCParameters).Name, "0", 1);
                    objQCParameters.QCRefNo = "QC/" + internalid;

                    int id = connection.Query <int>(sql, objQCParameters, trn).Single();
                    objQCParameters.QCParaId = id;
                    InsertLoginHistory(dataConnection, objQCParameters.CreatedBy, "Create", "Box", internalid.ToString(), "0");
                    //connection.Dispose();
                    trn.Commit();
                }
                catch (Exception ex)
                {
                    trn.Rollback();
                    objQCParameters.QCParaId = 0;
                    objQCParameters.QCRefNo  = null;
                }
                return(objQCParameters);
            }
        }
Exemplo n.º 3
0
        public ActionResult Edit(QCParameters model)
        {
            var repo = new QCParametersRepository();

            model.CreatedBy      = UserID.ToString();
            model.OrganizationId = OrganizationId;
            model.CreatedDate    = System.DateTime.Now;
            bool isexists = repo.IsFieldExists(repo.ConnectionString(), "QCParam", "QCParamName", model.QCParamName, "QCParamId", model.QCParamId);

            if (!isexists)
            {
                var result = new QCParametersRepository().UpdateQCParameter(model);

                if (result.OrganizationId > 0)
                {
                    TempData["Success"] = "Updated Successfully!";
                    TempData["QCRefNo"] = result.QCRefNo;
                    return(RedirectToAction("Create"));
                }
                else
                {
                    dropdown();
                    TempData["error"]   = "Oops!!..Something Went Wrong!!";
                    TempData["QCRefNo"] = null;
                    return(View("Edit", model));
                }
            }
            else
            {
                dropdown();
                TempData["error"]   = "This QCParameter Name Alredy Exists!!";
                TempData["QCRefNo"] = null;
                return(View("Create", model));
            }
        }
Exemplo n.º 4
0
        public ActionResult Delete(QCParameters model)
        {
            model.CreatedBy = UserID.ToString();
            int result = new QCParametersRepository().DeleteQCPara(model);

            if (result == 0)
            {
                TempData["Success"] = "Deleted Successfully!";
                TempData["QCRefNo"] = model.QCRefNo;
                return(RedirectToAction("Create"));
            }
            else
            {
                if (result == 1)
                {
                    TempData["error"]   = "Sorry!! You Cannot Delete this QCParameter It Is Already In Use";
                    TempData["QCRefNo"] = null;
                }
                else
                {
                    TempData["error"]   = "Oops!!..Something Went Wrong!!";
                    TempData["QCRefNo"] = null;
                }
                return(RedirectToAction("Create"));
            }
        }
Exemplo n.º 5
0
        public ActionResult Create()
        {
            ViewBag.Title = "Create";
            QCParameters QC = new QCParameters();

            QC.QCRefNo = "QC/" + DatabaseCommonRepository.GetNextReferenceNo(typeof(QCParameters).Name);
            dropdown();
            return(View(QC));
        }
Exemplo n.º 6
0
        public QCParameters UpdateQCParameter(QCParameters objQCParameters)
        {
            using (IDbConnection connection = OpenConnection(dataConnection))
            {
                string sql = @"Update QCParam Set QCParamName=@QCParamName,QCParaId=@QCParaId,QCRefNo=@QCRefNo,CreatedBy=@CreatedBy,CreatedDate=@CreatedDate,OrganizationId=@OrganizationId OUTPUT INSERTED.OrganizationId WHERE QCParamId=@QCParamId";


                var id = connection.Execute(sql, objQCParameters);
                InsertLoginHistory(dataConnection, objQCParameters.CreatedBy, "Update", "QCParam", id.ToString(), "0");
                return(objQCParameters);
            }
        }