Exemple #1
0
        public IHttpActionResult ModifyQAInputDetailAPI(dynamic data)
        {
            var             jsonData     = data.ToString();
            QAInputDetailVM qaMasterData = JsonConvert.DeserializeObject <QAInputDetailVM>(jsonData);
            var             result       = QualityService.ModifyQAInputDetail(qaMasterData);

            return(Ok(result));
        }
Exemple #2
0
        public QAInputDetailVM QuerySingleQAInputDetailInfoAPI(int QAInputDetailUID)
        {
            QAInputDetailVM result = new QAInputDetailVM();

            try
            {
                var query = (from QADetails in DataContext.QualityAssurance_InputDetail
                             join ExcetptionTYpe in DataContext.QualityAssurance_ExceptionType on QADetails.ExceptionType_UID equals ExcetptionTYpe.ExceptionType_UID
                             where QADetails.QualityAssurance_InputDetail_UID == QAInputDetailUID
                             select new QAInputDetailVM
                {
                    RepairNG_Qty = QADetails.RepairNG_Qty,
                    Repair_Qty = QADetails.Repair_Qty,
                    QualityAssurance_InputDetail_UID = QADetails.QualityAssurance_InputDetail_UID,
                    SepcialAccept_Qty = QADetails.SepcialAccept_Qty,
                    NG_Qty = QADetails.NG_Qty,
                    ExceptionType_UID = QADetails.ExceptionType_UID,
                    ExceptionTypeName = ExcetptionTYpe.TypeName,
                    QualityAssurance_InputMaster_UID = QADetails.QualityAssurance_InputMaster_UID,
                    CreateDate = QADetails.Create_Date,
                    Displace_Qty = QADetails.Displace_Qty
                }).Union(
                    from QADetails in DataContext.QualityAssurance_InputDetail_History
                    join ExcetptionTYpe in DataContext.QualityAssurance_ExceptionType on QADetails.ExceptionType_UID equals ExcetptionTYpe.ExceptionType_UID
                    where QADetails.QualityAssurance_InputDetail_UID == QAInputDetailUID
                    select new QAInputDetailVM
                {
                    RepairNG_Qty = QADetails.RepairNG_Qty,
                    Repair_Qty   = QADetails.Repair_Qty,
                    QualityAssurance_InputDetail_UID = QADetails.QualityAssurance_InputDetail_UID,
                    SepcialAccept_Qty = QADetails.SepcialAccept_Qty,
                    NG_Qty            = QADetails.NG_Qty,
                    ExceptionType_UID = QADetails.ExceptionType_UID,
                    ExceptionTypeName = ExcetptionTYpe.TypeName,
                    QualityAssurance_InputMaster_UID = QADetails.QualityAssurance_InputMaster_UID,
                    CreateDate   = QADetails.Create_Date,
                    Displace_Qty = QADetails.Displace_Qty
                });


                if (query.Count() != 0)
                {
                    result = query.Distinct().ToList()[0];
                }
            }
            catch (Exception ex)
            {
                log.Error(ex);
            }

            return(result);
        }
Exemple #3
0
        public string ModifyQAInputDetail(QAInputDetailVM data)
        {
            string result = "";

            try
            {
                string sql = string.Format(@"
                                            IF EXISTS ( SELECT TOP 1
                                                                1
                                                        FROM    dbo.QualityAssurance_InputDetail
                                                        WHERE   QualityAssurance_InputDetail_UID = {7}
                                                                AND Repair_Qty IS NOT NULL
                                                                AND SepcialAccept_Qty IS NOT NULL
                                                                AND RepairNG_Qty IS NOT NULL
                                                                AND NG_Qty IS NOT NULL )
                                            BEGIN
                                                INSERT INTO dbo.QualityAssurance_DataChangeLog
                                                    ( QualityAssurance_InputDetail_UID ,
                                                      QualityAssurance_InputMaster_UID ,
                                                      IsDeleted ,
                                                      LastRepair_Qty ,
                                                      LastSepcialAccept_Qty ,
                                                      LastNG_Qty ,
                                                      LastRepairNG_Qty ,
                                                      NewRepair_Qty ,
                                                      NewSepcialAccept_Qty ,
                                                      NewNG_Qty ,
                                                      NewRepairNG_Qty ,
                                                      Modified_UID ,
                                                      Modified_Date ,
                                                      ModifiedReason,
                                                      LastDisplace_Qty,
                                                      NewDisplace_Qty
                                                    )
                                            SELECT QualityAssurance_InputDetail_UID,
	                                               QualityAssurance_InputMaster_UID,
	                                               {0},
	                                               Repair_Qty,
	                                               SepcialAccept_Qty,
	                                               NG_Qty,
	                                               RepairNG_Qty,
	                                               {1},
	                                               {2},
	                                               {3},
	                                               {4},
	                                               {5},
	                                               GETDATE(),
	                                               N'{6}',
                                                   {8},
                                                   Displace_Qty
	                                               FROM dbo.QualityAssurance_InputDetail
	                                               WHERE QualityAssurance_InputDetail_UID={7}

                                            IF {0}=1
											BEGIN
											    UPDATE dbo.QualityAssurance_InputDetail SET IsDeleted={0} WHERE QualityAssurance_InputDetail_UID={7}
											END
											ELSE
											BEGIN
										        UPDATE dbo.QualityAssurance_InputDetail SET
                                                Repair_Qty={1},SepcialAccept_Qty={2},RepairNG_Qty={3},NG_Qty={4},
                                                Modified_UID={5},Modified_Date=GETDATE(), Displace_Qty={8}
                                                WHERE QualityAssurance_InputDetail_UID={7}
											END
   
                                            END
                                            ELSE
                                            BEGIN
	                                            DELETE FROM dbo.QualityAssurance_InputDetail WHERE QualityAssurance_InputDetail_UID = {7}
                                            END", data.IsDeleted ? 1 : 0, data.Repair_Qty == null ? 0 : data.Repair_Qty, data.SepcialAccept_Qty == null ? 0 : data.SepcialAccept_Qty,
                                           data.RepairNG_Qty == null ? 0 : data.RepairNG_Qty, data.NG_Qty == null ? 0 : data.NG_Qty, data.Modified_UID, data.ModifyReason.Replace("'", "''"), data.QualityAssurance_InputDetail_UID, data.Displace_Qty == null ? 0 : data.Displace_Qty);

                DataContext.Database.ExecuteSqlCommand(sql);
            }
            catch (Exception ex)
            {
                result = "Error";
                log.Error(ex);
            }
            result = "Success";
            return(result);
        }