예제 #1
0
        public void InitOrderShoot(string orderNO, string shootType)
        {
            try
            {
                if (shootType != ShootType.Outside)
                {
                    ExecuteNonQuery(string.Format(@"
                    IF NOT EXISTS (SELECT 1 FROM OrderShoot WHERE OrderNO = '{0}' AND ShootType = '内景' AND RecordState = 0)
                    BEGIN
	                    INSERT INTO OrderShoot(OrderNO, ShootType, ShootState, RecordState)
                        VALUES ('{0}', '内景', '初始化', 3)
                    END", orderNO));
                }
                if (shootType != ShootType.Inside)
                {
                    ExecuteNonQuery(string.Format(@"
                    IF NOT EXISTS (SELECT 1 FROM OrderShoot WHERE OrderNO = '{0}' AND ShootType = '外景' AND RecordState = 0)
                    BEGIN
	                    INSERT INTO OrderShoot(OrderNO, ShootType, ShootState, RecordState)
                        VALUES ('{0}', '外景', '初始化', 3)
                    END", orderNO));
                }
                LogManagement.SaveOperateLog(orderNO, LogType.Shoot, string.Format(@"初始化[{0}]摄影记录", shootType));
                LogManagement.SaveOrderLog(orderNO, LogType.Shoot, string.Format(@"初始化[{0}]摄影记录", shootType));
            }
            catch (Exception ex)
            {
                MessageBoxEx.Error(string.Format(@"初始化摄影记录失败!{0}{1}", Environment.NewLine, ex.Message));
            }
        }
예제 #2
0
        public void HandleNeedReShoot(string orderNO)
        {
            string strSql = string.Format(@"
                                            UPDATE FlagReshoot 
                                            SET FlagState = '已处理', HandleEmpNO = '{1}', HandleTime = GETDATE()  
                                            WHERE OrderNO = '{0}' AND FlagState = '正常'", orderNO, Information.CurrentUser.EmployeeNO);

            ExecuteNonQuery(strSql);
            LogManagement.SaveOperateLog(orderNO, LogType.Shoot, @"重拍标记已处理");
            LogManagement.SaveOrderLog(orderNO, LogType.Shoot, @"重拍标记已处理");
        }
예제 #3
0
        public void Deleted(string orderNO)
        {
            string strSql = string.Format(@"UPDATE OrderState SET IsDeleted = 1 WHERE OrderNO = '{0}'", orderNO);

            if (ExecuteNonQuery(strSql) <= 0)
            {
                return;
            }
            LogManagement.SaveOperateLog(orderNO, LogType.OrderStateChanged, @"使订单失效");
            LogManagement.SaveOrderLog(orderNO, LogType.OrderStateChanged, @"使订单失效");
        }
예제 #4
0
        public void CancelNeedReShoot(string orderNO)
        {
            string strSql = string.Format(@"
                                            UPDATE FlagReshoot 
                                            SET FlagState = '已取消'
                                            WHERE OrderNO = '{0}' AND FlagState = '正常'", orderNO);

            ExecuteNonQuery(strSql);
            LogManagement.SaveOperateLog(orderNO, LogType.Shoot, @"重拍标记已失效");
            LogManagement.SaveOrderLog(orderNO, LogType.Shoot, @"重拍标记已失效");
        }
예제 #5
0
 public bool FinishShoot(string orderNO, string shootType)
 {
     try
     {
         ExecuteNonQuery(shootType == ShootType.All ? string.Format(@"UPDATE OrderShoot SET ShootDate=GETDATE() WHERE OrderNO='{0}' AND RecordState = 0", orderNO) : string.Format(@"UPDATE OrderShoot SET ShootDate=GETDATE() WHERE orderNO='{0}' AND RecordState = 0 AND ShootType='{1}'", orderNO, shootType));
         LogManagement.SaveOperateLog(orderNO, LogType.Shoot, string.Format(@"设置[{0}]拍摄完成", shootType));
         LogManagement.SaveOrderLog(orderNO, LogType.Shoot, string.Format(@"设置[{0}]拍摄完成", shootType));
         return(true);
     }
     catch
     {
         return(false);
     }
 }
예제 #6
0
 public bool SetShootMemory(string orderNO, string memory)
 {
     try
     {
         ExecuteNonQuery(string.Format(@"UPDATE OrderShoot SET ShootMemory = '{0}' WHERE OrderNO = '{1}'", memory, orderNO));
         LogManagement.SaveOperateLog(orderNO, LogType.Shoot, string.Format(@"修改摄影备注为[{0}]", memory));
         LogManagement.SaveOrderLog(orderNO, LogType.Shoot, string.Format(@"修改摄影备注为[{0}]", memory));
         return(true);
     }
     catch (Exception ex)
     {
         MessageBoxEx.Error(ex.Message);
         return(false);
     }
 }
예제 #7
0
        public void NewOrder(string orderNO)
        {
            string strSql = string.Format(@"DECLARE @orderNO VARCHAR(20) = '{0}'
                                            IF NOT EXISTS(SELECT * FROM OrderState WHERE OrderNO = @orderNO AND IsDeleted = 0)
                                            BEGIN
	                                            INSERT INTO OrderState(OrderNO) VALUES(@orderNO)
                                            END", orderNO);

            if (ExecuteNonQuery(strSql) <= 0)
            {
                return;
            }
            LogManagement.SaveOperateLog(orderNO, LogType.OrderStateChanged, @"生成新订单");
            LogManagement.SaveOrderLog(orderNO, LogType.OrderStateChanged, @"生成新订单");
        }
예제 #8
0
        public void SetNeedReShoot(string orderNO, string type)
        {
            string strSql = string.Format(@"
                                            DECLARE @orderNO VARCHAR(30) = '{0}'
                                            DECLARE @shootType VARCHAR(10) = '{1}'
                                            DECLARE @flagEmpNO VARCHAR(50) = '{2}'
                                            IF EXISTS (SELECT 1 FROM FlagReshoot WHERE OrderNO = @orderNO AND FlagState = '正常')
                                            BEGIN
	                                            UPDATE FlagReshoot 
	                                            SET ShootType = @shootType, FlagTime = GETDATE(), FlagEmpNO = @flagEmpNO
	                                            WHERE OrderNO = @orderNO AND FlagState = '正常'
                                            END
                                            ELSE BEGIN
	                                            INSERT INTO FlagReshoot(OrderNO, ShootType, FlagTime, FlagEmpNO, FlagState) 
	                                            VALUES(@orderNO, @shootType, GETDATE(), @flagEmpNO, '正常')
                                            END", orderNO, type, Information.CurrentUser.EmployeeNO);

            ExecuteNonQuery(strSql);
            LogManagement.SaveOperateLog(orderNO, LogType.Shoot, string.Format(@"看样标记[{0}]需要重拍", type));
            LogManagement.SaveOrderLog(orderNO, LogType.Shoot, string.Format(@"看样标记[{0}]需要重拍", type));
        }
예제 #9
0
        public bool ReShoot(string orderNO, string shootType, string shootDepartment, string shootAddress, string shootAddressName, string shootEmployeeNO, string shootEmployeeName, string preShootDate, string shootMemory)
        {
            // 先将对应类型的摄影记录设置失效
            try
            {
                ExecuteNonQuery(string.Format(@"UPDATE OrderShoot SET RecordState = 2 WHERE OrderNO='{0}' AND RecordState = 0 AND ShootType='{1}' AND IsDelete=0", orderNO, shootType));
            }
            catch
            {
                return(false);
            }
            StringBuilder sb = new StringBuilder();

            sb.AppendLine(string.Format(@"            
            DECLARE 
            @orderNO VARCHAR(20) = '{0}',
            @shootType VARCHAR(10) = '{1}',
            @shootDepartment VARCHAR(30) = '{2}',
            @shootAddress VARCHAR(30) = '{3}',
            @shootEmployeeNO VARCHAR(30) = '{4}',
            @preShootDate VARCHAR(30) = '{5}',
            @shootMemory VARCHAR(MAX) = '{6}',
            @opEmployee VARCHAR(30) = '{7}',
            @opDepartment VARCHAR(30) = '{8}',
            @opDateTime DATETIME = GETDATE(),
            @shootAddressName VARCHAR(30) = '{9}',
            @shootEmployeeName VARCHAR(30) = '{10}'
	        INSERT INTO OrderShoot(OrderNO, ShootState, ShootType, ShootDepartment, ShootAddress, ShootEmployeeNO, PreShootDate, ShootMemory, OpEmployee, OpDepartment, OpDateTime)
	        VALUES(@orderNO, '重拍', @shootType, @shootDepartment, @shootAddress, @shootEmployeeNO, @preShootDate, @shootMemory, @opEmployee, @opDepartment, @opDateTime)"    , orderNO, shootType, shootDepartment, shootAddress, shootEmployeeNO, preShootDate, shootMemory, Information.CurrentUser.EmployeeNO, Information.CurrentUser.EmployeeDepartmentNO, shootAddressName, shootEmployeeName));
            if (shootType == ShootType.Inside)
            {
                sb.AppendLine(@"
                IF EXISTS
                (
	                SELECT 1 FROM OrdersSub WHERE OrderNO = @orderNO
                )
                BEGIN 
	                UPDATE OrdersSub 
	                SET 
	                ShootAddressNameN = @shootAddressName,
	                ShootEmployeeNameN = @shootEmployeeName
	                WHERE OrderNO=@orderNO
                END
                ELSE BEGIN
	                INSERT INTO OrdersSub(OrderNO, ShootAddressNameN, ShootEmployeeNameN) 
	                VALUES (@orderNO, @shootAddressName, @shootEmployeeName)
                END");
            }
            else if (shootType == ShootType.Outside)
            {
                sb.AppendLine(@"
                IF EXISTS
                (
	                SELECT 1 FROM OrdersSub WHERE OrderNO = @orderNO
                )
                BEGIN 
	                UPDATE OrdersSub 
	                SET 
	                ShootAddressNameW = @shootAddressName,
	                ShootEmployeeNameW = @shootEmployeeName
	                WHERE OrderNO=@orderNO
                END
                ELSE BEGIN
	                INSERT INTO OrdersSub(OrderNO, ShootAddressNameW, ShootEmployeeNameW) 
	                VALUES (@orderNO, @shootAddressName, @shootEmployeeName)
                END");
            }
            try
            {
                ExecuteNonQuery(sb.ToString());
                LogManagement.SaveOperateLog(orderNO, LogType.Shoot, string.Format(@"安排[{0}]重拍, 摄影地点[{1}], 摄影师[{2}], 预约时间[{3}], 摄影备注[{4}]", shootType, shootAddressName, shootEmployeeName, preShootDate, shootMemory));
                LogManagement.SaveOrderLog(orderNO, LogType.Shoot, string.Format(@"安排[{0}]重拍, 摄影地点[{1}], 摄影师[{2}], 预约时间[{3}], 摄影备注[{4}]", shootType, shootAddressName, shootEmployeeName, preShootDate, shootMemory));
                return(true);
            }
            catch
            {
                return(false);
            }
        }
예제 #10
0
        public bool DeleteShoot(string orderNO, string shootType)
        {
            string strSql;

            if (shootType == ShootType.All)
            {
                strSql = string.Format(@"
                UPDATE OrderShoot 
                SET RecordState = 1,IsDelete = 1
                WHERE OrderNO='{0}' 
                AND RecordState = 0", orderNO);
            }
            else
            {
                strSql = string.Format(@"
                UPDATE OrderShoot 
                SET RecordState = 1,IsDelete = 1
                WHERE OrderNO='{0}' 
                AND RecordState = 0
                AND ShootType = '{1}'", orderNO, shootType);
            }
            try
            {
                ExecuteNonQuery(strSql);
                LogManagement.SaveOperateLog(orderNO, LogType.Shoot, string.Format(@"删除了[{0}]摄控", shootType));
                LogManagement.SaveOrderLog(orderNO, LogType.Shoot, string.Format(@"删除了[{0}]摄控", shootType));
            }
            catch
            {
                return(false);
            }

            // 恢复上一条置为失效的记录,更新Orders对应日期
            switch (shootType)
            {
            case "内景":
                using (DataSet ds = ExecuteQuery(string.Format(@"SELECT * FROM OrderShoot WHERE OrderNO = '{0}' AND ShootType = '{1}' AND RecordState = 2 ORDER BY OpDateTime DESC", orderNO, shootType)))
                {
                    if (ds.IsEmpty())
                    {
                        // 直接更新Order
                        try
                        {
                            ExecuteNonQuery(string.Format(@"UPDATE Orders SET PreShootDateN = NULL, ShootDateN = NULL, ShootAddressN = NULL WHERE OrderNO='{0}'", orderNO));
                            return(true);
                        }
                        catch
                        {
                            return(false);
                        }
                    }
                    // 恢复记录,再对应更新Order
                    DataRow  dr                  = ds.Tables[0].Rows[0];
                    DateTime dtPreShoot          = dr["PreShootDate"].SafeDbDateTime();
                    DateTime dtShoot             = dr["ShootDate"].SafeDbDateTime();
                    string   strUpdateOrder      = string.Format(@"UPDATE Orders SET PreShootDateN = '{0}', ShootDateN = '{1}', ShootAddressN = '{2}' WHERE OrderNO='{3}'", dtPreShoot.Equals(DateTime.MinValue) ? "1900-01-01" : dtPreShoot.ToString(CultureInfo.CurrentCulture), dtShoot.Equals(DateTime.MinValue) ? "1900-01-01" : dtShoot.ToString(CultureInfo.CurrentCulture), dr["ShootAddress"].SafeDbString(), orderNO);
                    string   strUpdateOrderShoot = string.Format(@"UPDATE OrderShoot SET RecordState = 0 WHERE ID = {0}", dr["ID"].SafeDbInt32());
                    try
                    {
                        ExecuteNonQuery(string.Format(@"{0} {1}", strUpdateOrder, strUpdateOrderShoot));
                        LogManagement.SaveOperateLog(orderNO, LogType.Shoot, string.Format(@"恢复了ID为[{0}]的摄影记录", dr["ID"].SafeDbInt32()));
                        LogManagement.SaveOrderLog(orderNO, LogType.Shoot, string.Format(@"恢复了ID为[{0}]的摄影记录", dr["ID"].SafeDbInt32()));
                        return(true);
                    }
                    catch
                    {
                        return(false);
                    }
                }

            case "外景":
                using (DataSet ds = ExecuteQuery(string.Format(@"SELECT * FROM OrderShoot WHERE OrderNO = '{0}' AND ShootType = '{1}' AND RecordState = 2 ORDER BY OpDateTime DESC", orderNO, shootType)))
                {
                    if (ds.IsEmpty())
                    {
                        // 直接更新Order
                        try
                        {
                            ExecuteNonQuery(string.Format(@"UPDATE Orders SET PreShootDateW = NULL, ShootDateW = NULL, ShootAddressW = NULL WHERE OrderNO='{0}'", orderNO));
                            return(true);
                        }
                        catch
                        {
                            return(false);
                        }
                    }
                    // 恢复记录,再对应更新Order
                    DataRow  dr                  = ds.Tables[0].Rows[0];
                    DateTime dtPreShoot          = dr["PreShootDate"].SafeDbDateTime();
                    DateTime dtShoot             = dr["ShootDate"].SafeDbDateTime();
                    string   strUpdateOrder      = string.Format(@"UPDATE Orders SET PreShootDateW = '{0}', ShootDateW = '{1}', ShootAddressW = '{2}' WHERE OrderNO='{3}'", dtPreShoot.Equals(DateTime.MinValue) ? "1900-01-01" : dtPreShoot.ToString(CultureInfo.CurrentCulture), dtShoot.Equals(DateTime.MinValue) ? "1900-01-01" : dtShoot.ToString(CultureInfo.CurrentCulture), dr["ShootAddress"].SafeDbString(), orderNO);
                    string   strUpdateOrderShoot = string.Format(@"UPDATE OrderShoot SET RecordState = 0 WHERE ID = {0}", dr["ID"].SafeDbInt32());
                    try
                    {
                        ExecuteNonQuery(string.Format(@"{0} {1}", strUpdateOrder, strUpdateOrderShoot));
                        LogManagement.SaveOperateLog(orderNO, LogType.Shoot, string.Format(@"恢复了ID为[{0}]的摄影记录", dr["ID"].SafeDbInt32()));
                        LogManagement.SaveOrderLog(orderNO, LogType.Shoot, string.Format(@"恢复了ID为[{0}]的摄影记录", dr["ID"].SafeDbInt32()));
                        return(true);
                    }
                    catch
                    {
                        return(false);
                    }
                }

            case "全套":
                using (DataSet dsN = ExecuteQuery(string.Format(@"SELECT * FROM OrderShoot WHERE OrderNO = '{0}' AND ShootType = '内景' AND RecordState = 2 ORDER BY OpDateTime DESC", orderNO)),
                       dsW = ExecuteQuery(string.Format(@"SELECT * FROM OrderShoot WHERE OrderNO = '{0}' AND ShootType = '外景' AND RecordState = 2 ORDER BY OpDateTime DESC", orderNO)))
                {
                    if (dsN.IsEmpty())
                    {
                        // 直接更新Order
                        try
                        {
                            ExecuteNonQuery(string.Format(@"UPDATE Orders SET PreShootDateN = NULL, ShootDateN = NULL, ShootAddressN = NULL WHERE OrderNO='{0}'", orderNO));
                        }
                        catch
                        {
                            return(false);
                        }
                    }
                    else
                    {
                        // 恢复记录,再对应更新Order
                        DataRow  dr                  = dsN.Tables[0].Rows[0];
                        DateTime dtPreShoot          = dr["PreShootDate"].SafeDbDateTime();
                        DateTime dtShoot             = dr["ShootDate"].SafeDbDateTime();
                        string   strUpdateOrder      = string.Format(@"UPDATE Orders SET PreShootDateN = '{0}', ShootDateN = '{1}', ShootAddressN = '{2}' WHERE OrderNO='{3}'", dtPreShoot.Equals(DateTime.MinValue) ? "1900-01-01" : dtPreShoot.ToString(CultureInfo.CurrentCulture), dtShoot.Equals(DateTime.MinValue) ? "1900-01-01" : dtShoot.ToString(CultureInfo.CurrentCulture), dr["ShootAddress"].SafeDbString(), orderNO);
                        string   strUpdateOrderShoot = string.Format(@"UPDATE OrderShoot SET RecordState = 0 WHERE ID = {0}", dr["ID"].SafeDbInt32());
                        try
                        {
                            ExecuteNonQuery(string.Format(@"{0} {1}", strUpdateOrder, strUpdateOrderShoot));
                            LogManagement.SaveOperateLog(orderNO, LogType.Shoot, string.Format(@"恢复了ID为[{0}]的摄影记录", dr["ID"].SafeDbInt32()));
                            LogManagement.SaveOrderLog(orderNO, LogType.Shoot, string.Format(@"恢复了ID为[{0}]的摄影记录", dr["ID"].SafeDbInt32()));
                        }
                        catch
                        {
                            return(false);
                        }
                    }

                    if (dsW.IsEmpty())
                    {
                        // 直接更新Order
                        try
                        {
                            ExecuteNonQuery(string.Format(@"UPDATE Orders SET PreShootDateW = NULL, ShootDateW = NULL, ShootAddressW = NULL WHERE OrderNO='{0}'", orderNO));
                            return(true);
                        }
                        catch
                        {
                            return(false);
                        }
                    }
                    else
                    {
                        // 恢复记录,再对应更新Order
                        DataRow  dr                  = dsW.Tables[0].Rows[0];
                        DateTime dtPreShoot          = dr["PreShootDate"].SafeDbDateTime();
                        DateTime dtShoot             = dr["ShootDate"].SafeDbDateTime();
                        string   strUpdateOrder      = string.Format(@"UPDATE Orders SET PreShootDateW = '{0}', ShootDateW = '{1}', ShootAddressW = '{2}' WHERE OrderNO='{3}'", dtPreShoot.Equals(DateTime.MinValue) ? "1900-01-01" : dtPreShoot.ToString(CultureInfo.CurrentCulture), dtShoot.Equals(DateTime.MinValue) ? "1900-01-01" : dtShoot.ToString(CultureInfo.CurrentCulture), dr["ShootAddress"].SafeDbString(), orderNO);
                        string   strUpdateOrderShoot = string.Format(@"UPDATE OrderShoot SET RecordState = 0 WHERE ID = {0}", dr["ID"].SafeDbInt32());
                        try
                        {
                            ExecuteNonQuery(string.Format(@"{0} {1}", strUpdateOrder, strUpdateOrderShoot));
                            LogManagement.SaveOperateLog(orderNO, LogType.Shoot, string.Format(@"恢复了ID为[{0}]的摄影记录", dr["ID"].SafeDbInt32()));
                            LogManagement.SaveOrderLog(orderNO, LogType.Shoot, string.Format(@"恢复了ID为[{0}]的摄影记录", dr["ID"].SafeDbInt32()));
                            return(true);
                        }
                        catch
                        {
                            return(false);
                        }
                    }
                }

            default:
            {
                return(false);
            }
            }
        }
예제 #11
0
        public void AutoDetectState(string orderNO)
        {
            using (DataSet ds = OrderShoot.GetOrderShootRecords(orderNO))
            {
                // 没有记录,新订单
                if (null == ds || null == ds.Tables[0])
                {
                    return;
                }

                using (DataTable dt = ds.Tables[0])
                {
                    string strShootType = ExecuteScalar(string.Format(@"SELECT ShootSites FROM Orders WHERE OrderNO = '{0}' AND IsDelete = 0", orderNO)).SafeDbString();
                    if (string.IsNullOrEmpty(strShootType))
                    {
                        return;
                    }

                    if (strShootType == ShootType.Inside)
                    {
                        DataRow[] drs = dt.Select("ShootType = '内景' AND RecordState = 0", "OpDateTime DESC");
                        // 没有拍摄记录,回到新订单
                        if (drs.Length <= 0)
                        {
                            ReturnToNewOrder(orderNO);
                        }
                        else
                        {
                            // 有拍摄记录,且完成了,切换到拍摄完成
                            DataRow dr = drs[0];
                            if (!DateTimeNotSet(dr["ShootDate"].SafeDbDateTime()))
                            {
                                ShootFinished(orderNO);
                            }
                        }
                    }
                    else if (strShootType == ShootType.Outside)
                    {
                        DataRow[] drs = dt.Select("ShootType = '外景' AND RecordState = 0", "OpDateTime DESC");
                        // 没有拍摄记录,回到新订单
                        if (drs.Length <= 0)
                        {
                            ReturnToNewOrder(orderNO);
                        }
                        else
                        {
                            // 有拍摄记录,且完成了,切换到拍摄完成
                            DataRow dr = drs[0];
                            if (!DateTimeNotSet(dr["ShootDate"].SafeDbDateTime()))
                            {
                                ShootFinished(orderNO);
                            }
                        }
                    }
                    else if (strShootType == ShootType.All)
                    {
                        DataRow[] drsW = dt.Select("ShootType = '外景' AND RecordState = 0", "OpDateTime DESC");
                        DataRow[] drsN = dt.Select("ShootType = '内景' AND RecordState = 0", "OpDateTime DESC");
                        // 内外都没有拍摄记录,回到新订单
                        if (drsN.Length <= 0 && drsW.Length <= 0)
                        {
                            ReturnToNewOrder(orderNO);
                        }
                        else if (drsN.Length > 0 && drsW.Length > 0)
                        {
                            // 有拍摄记录,且都完成了,切换到拍摄完成
                            DataRow drN = drsN[0];
                            DataRow drW = drsW[0];
                            if (!DateTimeNotSet(drN["ShootDate"].SafeDbDateTime()) && !DateTimeNotSet(drW["ShootDate"].SafeDbDateTime()))
                            {
                                ShootFinished(orderNO);
                            }
                        }
                    }
                }
            }
            LogManagement.SaveOperateLog(orderNO, LogType.OrderStateChanged, @"由于删除了摄控,系统重新判断订单当前状态");
            LogManagement.SaveOrderLog(orderNO, LogType.OrderStateChanged, @"由于删除了摄控,系统重新判断订单当前状态");
        }
예제 #12
0
 private static void SaveSimpleOperateLog(string orderNO, string stateFrom, string stateTo)
 {
     LogManagement.SaveOperateLog(orderNO, LogType.OrderStateChanged, string.Format(@"将订单状态由[{0}]变为[{1}]", stateFrom, stateTo));
     LogManagement.SaveOrderLog(orderNO, LogType.OrderStateChanged, string.Format(@"将订单状态由[{0}]变为[{1}]", stateFrom, stateTo));
 }